Hi!
I have a grid that gets a values from subGrid like this
+ Men
- John
- Adam
+ Women
- Ann
- Kati
I would like to block main nodes (Men,Women) form selecting, the best solution is to expand sub nodes on click instead of default selecting values to main grid.
Hello,
you can use onRowSelect event handler to open sub grid when wen or women row is selected:
grid.attachEvent(“onRowSelect”,function(row_id,ind){
if(row_id==“id_men”||row_id==“id_women”)
grid.cells(id,0).open();
grid.clearSelection();
})
This solution partly works - root values are not transferred to main grid, but subGrid closes on “Man/Woman” clicks.
Sorry for the misleading information. There was an issue in the provided code snippet - the correct is grid.cells(row_id,0).open(); instead of grid.cells(id,0).open();
This solution works perfectly locally. So, please contact us at support@dhtmlx.com, provide your ref. number and we’ll send you the sample.
I gets:
subgridPluto_1369763_.cells(rowID, 0).open is not a function
By subGrid structure is
grandparent <-this is not selectable
—child <-this is selectable selectable
—parent <-this is not selectable
------child <-this is selectable selectable
I manage to open row by:
subgridportlet:namespace/.openItem(rowID);
But, after opening the subGrit gets closed, I would like to know how to prevent closing subGrid when not selectable row is clicked?
You can use “onSubRowOpen” event, which fires , each time when sub-row opened|closed, and define any kind of rules
mygrid.attachEvent(“onSubRowOpen”,function(row_id,state){
if (!state&&row_id==“ID_OF_NOT_SELECTABLE_ROW”){
mygrid.grid.cells(row_id,0).open();
}
});
Once again - I manage to open rows on click, my current problem is that subGrid closes on every row click, even when clicked row is not selectable.
I other words, I dont know how to prevent subGrid from closing on any click.
After some grid’s or subGrid’s rows closing “onSubRowOpen” event occurs. You can catch that event and open necessary row again. There is no another way to block some row from closing/opening. You can try to use dhtmlxTreeGrid which has more extended parent-child functionality. Please see more information here dhtmlx.com/docs/products/dht … ndex.shtml
In my example the subGrid is in fact treegrid
In such case you can use following events:
mygrid.attachEvent(“onRowSelect”,function(row_id,cellIndex){
if(row_id==“id_men”||row_id==“id_women”){
mygrid.openItem(row_id);
mygrid.clearSelection();
}
});
mygrid.attachEvent(“onOpenStart”,function(id,state){
if (state==1&&(row_id==“id_men”||row_id==“id_women”)) return false;
else return true;
});
I try this and:
1. selectable rows are clickable OK
2. not selectable rows are not transferred to main grid OK
3. when I click on non selectable row the subGrid are closed - and this is wrong because no selection has been made NOT OK
Hello,
The event handler that was recommended in the previous answer must solve the third issue - the subrows of locked rows don’t close when you select locked (parent) row.
mygrid.attachEvent(“onOpenStart”,function(id,state){
if (state==1&&(id==“id_men”||id==“id_women”)) return false; /if a row is open, it won’t be closed/
else return true;
});
Do you use this approach ?