Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Sunchaser on Oct 20, 2008 13:57
open dhtmlx forum
Grid / how to get the "idd" value from a row

HI,

I would like to know how I can get to the "idd" propoerty of a row ("tr" object, like "tr.ev_light") ?
I'll have to do some customisation after using "Groupby()", but I don't know how to access to some properties like this one (I'm not enough experienced in html / javascript may be).

Thanks,
Regards.
Answer posted by Support on Oct 21, 2008 03:02
You can try to get row's id by the following approach:

    var id = row_obj.idd;


Answer posted by Sunchaser on Oct 21, 2008 06:28
Hi,
Thanks,
In fact, I would like to know how I can get the "structure" / "hierarchy" of these objects, I mean the way to access to some "childs" of grid object; something like:
" the_grid->grid__body->Rows->Row[x]->...etc"
Looking at the DOM with the "firebug" tool in firefox, I can see these particular objects and properties but I don't know how to reach them.
It seems somethimes easy, as I can find some header cells like "grid.hdr.rows[1].cells[4]", but not for all the part of the grid.

Thx,

Answer posted by Support on Oct 21, 2008 08:12
The API of grid hides the inner collections, so you need not have access to them to execute any API operation. 
Technically there are 3 inner collections
grid.rowsAr - id => row  
grid.rowBuffer - real index = > row
grid.rowsCol - visible index => row

each row has two mandatory properties
   row.idd - row id
   row._attrs - collection of all other grid specific attributes

Those collection can be used to locate necessary rows in grid.
The header rows has not any inner refferences
Technically 
  grid.hdr - HTML table of header part
  grid.obj - HTML table of data part

In case of split the right part of grid is a separate grid instance , which can be accessed as 
  grid._fake



Answer posted by Support on Oct 21, 2008 08:16
>>I can get the "structure" / "hierarchy" of these objects
The order of plain grid defined by order in rowsBuffer collection ( it has more complex storage in case of treeGrid )
In case of grouping , there are grid._groups collection, which contains info about groups in grid

In most cases , the customization can be done through public API,  can you please provide more info which effect you want to achieve
Answer posted by Sunchaser on Oct 21, 2008 09:08

Thanks for your answer,

It's very interesting.

I have, for the moment,  an additionnal checkBox in the group_row in order to select/unselect "children rows" of this group (but the idea was to be able to put/use any object in that part),  an additionnal text displayed with the text of the group (depending on "dynamic conditions" / "dynamic values").

But nothing very "clean" for the moment, I still have few problems when the group is collapsed/expanded, but not in all cases so in fact - for me - it's more difficult to understand why ...

I'll take a look at the collections you detailled, thanks, may be it could help me, anyway.

Regards.

Answer posted by Support on Oct 21, 2008 10:06
Unfortunately the groups in grid is more a special view than strict structure. 
You can "do something for group" as 

grid.forEachRow(function(id){
 if (grid.cells(id,grindex).getValue()==grvalue){
     //do something 
     // id - id of row in group
     grid.cells(id,0).setValue(1); //set checkbox
 }
});

grindex - index by which grid grouped
grvalue - group value

The more fast but not so "legal" way to process group will be 

var row = grid._groups[grvalue].row; //row object, which hold group information
var ind=grid.rowsCol._dhx_find(z.row)+1;
while(grid.rowsCol[ind] && !grid.rowsCol[ind]._cntr){
  // do anything
  grid.cells(grid.rowsCol[ind].idd,0).setValue(1);//set checkbox
  ind++;
 }


Answer posted by Sunchaser on Oct 21, 2008 11:12

Hi,

 

It sounds really nice, I'm going to try something like that and will let you know if I get better things that I've now.

Really thank you, I don't think I'll have found the "_groups[..]" idea alone.

Regards.