Show only one window by click on grid row

Hello everybody,
I am a newbee in dhtmlx and make my first steps with java script frameworks. The most components of DHTMLX are very easy to use, but I ´ve got a problem with windows by clicking a grid row. This is my code, which shows a data grid.

// Grid Master
ablGridMaster = ablTabbar.cells(“a1”).attachGrid();
ablGridMaster.setImagePath(“…/…/dhtmlx/imgs/”); ablGridMaster.setHeader(“Kommission,NeubauNr,Kunde,Liefertermin,KW,Auftragsart,Bestellung,Beschreibung”);
ablGridMaster.attachHeader(“#text_filter,#text_filter,#select_filter,#text_filter,#select_filter,#select_filter, , “);
ablGridMaster.setInitWidths(“75,120,150,80,90,150,,”);
ablGridMaster.setColAlign(“left,left,left,right,right,left,left,left”);
ablGridMaster.setColTypes(“ro,ro,ro,ro,ro,ro,ro,ro”);
ablGridMaster.setColSorting(“int,str,str,date,str,str,str,str”);
ablGridMaster.enableMultiline(true);
ablGridMaster.init();
ablGridMaster.loadXML(“xml/master.xml”);
ablGridMaster.attachEvent(“onRowSelect”, function (rID,cInd){
dhxWins = new dhtmlXWindows();
dhxWins.createWindow(“ablDetailsWin”, 10, 10, 800, 600);
dhxWins.setImagePath(”…/…/codebase/imgs/”);
dhxWins.window(“ablDetailsWin”).setText(rID);
});

This works fine, but it will create a new window for every click on a row. I want only one window.

After searching in the docs, I found this page.

dhtmlx.com/docs/products/dht … _init.html

Theres is a loop which shows an alert message, if more than 5 windows are open. I tried to use this snippet, but it will not work. Anybody there, who can help me?

Please be thoughtfully, I am over 50 years old and will learn :wink:

Kindly regards from germany
Daniel

Hello Daniel,

you are right. It would be better to create only one window and reset its header and content:

[code]dhxWins = new dhtmlXWindows();

ablGridMaster.attachEvent(“onRowSelect”, function (rID,cInd){
if(!dhxWins.window(“ablDetailsWin”)){
var win = dhxWins.createWindow(“ablDetailsWin”, 10, 10, 800, 600);
win.attachEvent(“onClose”,function(){
win.hide();
return false;
});
}
else
win.show();
dhxWins.window(“ablDetailsWin”).setText(rID);
});[/code]

If onClose event handler doesn’t return true, a window won’t be closed and you may call hide() to hide the window.

Hello Alexandra,

thanks for support. I tried your script but it don´t works correctly. I got only one window, that´s right, but after click on another row, the header doesn´t update. I played with some parameters and now it works very fine.

This is the modified script, which works right

ablGridMaster.attachEvent("onRowSelect", function (rID,cInd){
	if(!dhxWins.window("ablDetailsWin")){
		win = dhxWins.createWindow("ablDetailsWin", 10, 10, 800, 600);
		win.attachEvent("onClose",function(){
			win.hide;
			return true;
		});	
	}
	else
	win.show("ablDetailsWin");
	dhxWins.window("ablDetailsWin").setText(rID);

Thank you very much and kindly regards
Daniel

Hi,

yes, there was a typo in my previous reply. There should be dhxWins.window(“ablDetailsWin”).show(); instead of win.show();