Table/Grid with clickable cells

Hello everybody,

I need to build a table/grid, where each cell has to be clickable (so each cell have to be an id), I tried 2 methods:

  • I started with the grid component but I noted that on click event is returned the row id.
  • I tried to use the dataview but in this case i can not manage the number of cells for each row, and nether the dimension of the each cell (to build the column)
  • I tried to split the scroll view in different layouts (a layout for each row) and associating a dataview for each layout. In this case the layout module split the view in equal sizes so if I have 2 rows, between a row and another there is more space than when I have 3 rows.

But all the 3 methods showed above did not work for my requirements.

Do you have a solution for my case. Or I have to buid a table? (and in this case can i manage the click events on each row?)

Thanks in advance for your help
Kind regards

Danilo

Hello,

Grid doesn’t provide built-in method to set onclick event for cell. However, you can set it by on_click object for “dhx_td”:

$$(“mygrid”).on_click[“dhx_td”] = function(e){

}

Here is the example:

$$("grid").on_click["dhx_td"] = function(e){ var itemId = dhx.html.locate(e,"dhx_f_id"); var node = e.target; while(node.tagName!="TD") node = node.parentNode; var row = node.parentNode; var index; for(var i=0;i<row.childNodes.length;i++){ if(row.childNodes[i] == node) index = i; } alert(itemId+";"+index) }