I use WebHierarchicalDataGrid with two levels.
I need to implement following scenario:
1. The grid's initially populated only with first-level rows. (the rows have no child rows)
2. User does some action (for ex. clicks on a button) and a child row is added to the selected parent row.
I've done it in following way:
var selectedRow = getSelectedRow(); var childGrid = selectedRow.get_rowIslands()[0]; var row = new Array(""); childGrid.get_rows().add(row);
This approach works fine if parent row already has at least one child row, but if there is no child rows I get null reference exception: selectedRow.get_rowIslands() returns empty array.
Please help!
Hi, David!
Thank you for your suggestion, but there is a problem
I've created my behaivor, inherited from GridBehavior, and implemented IEmptyRowIslands , that returns true. But after postback I get inner exception. If you have an example on how create custom behaviour, could you please send it me.
Now I've partially solved my problem by adding RowAdding behaviour and hidding it using css.
But could you tell me is it possible to not show (somehow hide) subgrids for rows that actually haven't any children? Now for each row(without children) the "Collapse/Expand" button is shown as well as subgrid containing only headers.
Please help.
Hi Alexander,
The grid as it stands now could not work around this. RowAdding implements IEmptyRowIslands interface to allow the child. What you could do is create a custom behavior that implements this interface and returns true for its property. Then add that behavior to the child band. This will allow the child to show even without row adding.
regards,David Young
RowAdding behaviour is off, because
1. I add new rows using my own button (not inline functionality) and I don't want this additional line (that allows to add new rows) will be shown.
2. I don't want that empty child grid will be shown for the user (it looks not good)
Is it possible to workaround theese problems?
Alexander
The child grid has to actually exist on the client for this to work. If you have the RowAdding behavior turned on in the child, then an empty grid will be made.