Grid strange code


#1

I’m trying to insert a really simple grid with a database connection in a Layout. The code is:

		myGrid = myLayout.cells("a").attachGrid({});
		myGrid.setImagePath("dhtmlx/codebase/imgs/")
		myGrid.setHeader("Tipo, Termine, N°, Cliente, Polizza, Importo");
		myGrid.setColTypes("ro,ron,ron,rotxt,rotxt,ron");
		myGrid.setColSorting("connector,connector,connector,connector,connector,connector")
		myGrid.setNumberFormat("0,000.00",5,".","'"); 
		myGrid.setDateFormat("%d/%m/%Y", "%Y-%m-%d"); // 05/26/2010, 2010/05/26
		myGrid.setColAlign("left,left,left,left,center,right")
		myGrid.init();
		myGrid.load("01a_sql_basic_connector.php");
		myGrid.enableAutoWidth(true);
		myGrid.enableAlterCss("even","uneven");
		myGrid.setStyle("font-size:12px; text-align:center; color: #666;", "font-size:11px;","", "");
		myGrid.setColWidth(0,"8");
		myGrid.setColWidth(1,"64");
		myGrid.setColWidth(2,"40");
		myGrid.setColWidth(3,"120");
		myGrid.setColWidth(4,"94");
		myGrid.setColWidth(5,"58");
		
		myGrid.forEachRow(function(id){
			myGrid.setCellTextStyle(id,2,"font-weight:bold;")
		});

I noticed some problem with this cose:

  1. the last part of the code that should change the font-weight of the second row to bold worked with the xml file, now with the connection it’s not working.
  2. it’s possible to change the margins on the table?
  3. even some advice on the code would be welcome :stuck_out_tongue:

Thank you in advance :slight_smile:


#2

Please, try to call this code from the callback fucntion of the load() method or from the onXLE event:

		myGrid = myLayout.cells("a").attachGrid({});
		myGrid.setImagePath("dhtmlx/codebase/imgs/")
		myGrid.setHeader("Tipo, Termine, N°, Cliente, Polizza, Importo");
		myGrid.setColTypes("ro,ron,ron,rotxt,rotxt,ron");
		myGrid.setColSorting("connector,connector,connector,connector,connector,connector")
		myGrid.setNumberFormat("0,000.00",5,".","'"); 
		myGrid.setDateFormat("%d/%m/%Y", "%Y-%m-%d"); // 05/26/2010, 2010/05/26
		myGrid.setColAlign("left,left,left,left,center,right")
		myGrid.init();
		myGrid.enableAutoWidth(true);
		myGrid.enableAlterCss("even","uneven");
		myGrid.setStyle("font-size:12px; text-align:center; color: #666;", "font-size:11px;","", "");
		myGrid.setColWidth(0,"8");
		myGrid.setColWidth(1,"64");
		myGrid.setColWidth(2,"40");
		myGrid.setColWidth(3,"120");
		myGrid.setColWidth(4,"94");
		myGrid.setColWidth(5,"58");
		myGrid.load("01a_sql_basic_connector.php",function(){
			myGrid.forEachRow(function(id){
				myGrid.setCellTextStyle(id,2,"font-weight:bold;")
			});
		});

#3

Unfortunately the problem cannot be reconstructed locally.
If the problem still occurs for you please, provide a complete demo or a demo link, where the problem can be reconstructed.