Please help me :( DHTMLXGRID AND DHTMLXTOOLBAR

Hello,

I get mygrid is undefined error on the following code… Does anyone know what I am doing wrong?

		function loadGridBox(id,select){
			//dhxLayout.progressOn();
			dhxLayout.cells("b").progressOn();
			dhxToolbar = dhxLayout.cells("b").attachToolbar();
			dhxToolbar.setSkin("dhx_skyblue");
			dhxToolbar.setIconsPath("js/dhtmlxToolbar/samples/common/imgs/");
			dhxToolbar.loadXML("js/dhtmlxToolbar/samples/common/dhxtoolbar_button.xml?" + new Date().getTime());
			
			var mygrid = dhxLayout.cells("b").attachGrid();
			mygrid.setImagePath("dhtmlxGrid/codebase/imgs/");                             
			mygrid.setColAlign("left,left,left,left,left,left,left,left");
			if(id == 'creative_qa'){
					mygrid.attachHeader("#text_filter,#text_filter,#select_filter,#select_filter,#select_filter"); 
				}else{
				mygrid.attachHeader("#text_filter,#text_filter,#rspan,#rspan,#select_filter,#select_filter,#select_filter"); 
				}
			mygrid.setSkin("dhx_skyblue");
			mygrid.init();
			mygrid.loadXML("grids/inbox_" + id + ".php", function(){dhxLayout.cells("b").progressOff();})
			myDataProcessor = new dataProcessor("listeners/" + id + "Update.php");
			myDataProcessor.init(mygrid);
			dhxToolbar.attachEvent("onClick", openSelectedItem());
        		}

		function openSelectedItem(id,mygrid){
			alert(mygrid.getSelectedId());
		}

Thanks :slight_smile:)

Just to clarify… When this function is called I get the error

function openSelectedItem(id,mygrid){
alert(mygrid.getSelectedId());
}

OnClick event of dhtmlxToolbar has only one attrbute in it’s function: id.

function openSelectedItem(id){ alert(mygrid.getSelectedId()); }

Please, read the following tutorial:
http://docs.dhtmlx.com/doku.php?id=dhtmlxtoolbar:event_onclick