sample code needed for dhtmlgrid and ajax call for each row

Hi,

I am quite new to dhtmlx. Would someone have some sample code to start this:

  1. Show a dhtmlx grid with 3 columns and 5 rows. The first column for each row shows a spinning wheel - some sort of progress bar indicator. The other two cells are strings.

  2. For each row an async ajax call is to be made. Once a callback is processed for a particular row the spinning wheel for that row is to be replaced with Y or N (or a checkbox for that matter).

Is that possible?

Thanks in advance,
Radu.

  1. To add image to the grid cell you can use “img” eXcell type. Please check example here dhtmlx.com/docs/products/dht … extra.html

  2. If you need call additional Ajax requests you can use dhtmlxAjax library. Tutorial is available here docs.dhtmlx.com/doku.php?id=dhtmlxajax:toc
    To change value of the cell you can use setValue() method.
    Please check more information here docs.dhtmlx.com/doku.php?id=dhtm … of_excells

Olga,

Thanks for the links. Bits and pieces - it will take me a while… I wonder since dhtmlajax does not have many sample examples - could the above use case scenario make it into a sample? It will be a practical illustration how to make ajax calls for dhtmlx grid.

Regards,
Radu

It will be a practical illustration how to make ajax calls for dhtmlx grid.
Please specify for what propose will you use Ajax call for the grid rows?

If you want save changes from grid, you can use dhtmlxDataProcessor library. The library monitors changes in the grid and uses a simple protocol to interchange with the server side code.
Please check examples here docs.dhtmlx.com/doku.php?id=dhtm … cessor:toc

My use case is simple - once the page is loaded 5 ajax http get async calls are made. When they bring info - a corresponding row is updated.

No need for saving data to the server side.

Regards,
Radu

To update some rows in the grid you may use updateFromXML() method. docs.dhtmlx.com/doku.php?id=dhtm … atefromxml

If this method doesn’t fit your need you should call custom Ajax request and update each cell in the grid with setValue() method.

mygrid.cellById(row_id,cell_index).setValue('new value');

Olga,

All the above links you pasted gives one just a general idea how separate functionality is used. Please consider enriching the current sample with the above use case. With little bit of work - you can have more customers. It is a really simple use case but illustrates a lot of dhtmlxgrid usage.

Back to my problem. I am trying now to use forEachRow function. My script is inside the attached jsp - which btw is included from another jsp - so I really have no access to <body onLoad… How do I see the alerts?

<link rel="STYLESHEET" type="text/css" href="css/dhtmlXGrid.css">
	<script  src="js/dhtmlXCommon.js"></script>
	<script  src="js/dhtmlXGrid.js"></script>
	<script  src="js/dhtmlXGridCell.js"></script>
	<script  src="js/dhtmlXTreeGrid.js"></script>
	
<div id="dmo_assistant_gridbox" width="100%" height="156px" style="background-color:white;"></div>

<script>
		mygrid = new dhtmlXGridObject('dmo_assistant_gridbox');
		mygrid.selMultiRows = true;
		mygrid.imgURL = "imgs/";
		mygrid.setHeader("Status,System,Task Description");
		mygrid.setInitWidths("90,50,165")
		mygrid.setColAlign("left,left,left")
		mygrid.setColTypes("tree,ed,txt");
		mygrid.setColSorting("str,str,str")
		mygrid.init();
		mygrid.loadXML("data/dmoa_tasks.xml");

		mygrid.forEachRow(function(id){
		    alett('am i here');
			alert(mygrid.cells(id,2).getValue());
	   	});
</script>

Thanks,
Radu

You should change your code like this:

mygrid.loadXML("data/dmoa_tasks.xml",fucntion(){ mygrid.forEachRow(function(id){ alert('am i here'); alert(mygrid.cells(id,2).getValue()); }); });

I saw the mispelled one - even before - taken the alett line out still not works.

For your information I have solved my problem:

...
	      mygrid.loadXML("data/dmoa_tasks.xml");
	      mygrid.attachEvent("onRowCreated", function(rId,rObj,rXml){
	    	  srartResearch('123',rId);
    	  });
...

Regards,
Radu