Could I get some code examples of how to keep what rows are expanded and collapse in an UltraWebGrid after a postback? My grid is grouped by a column and is initially collapsed on load, buth then the users expand. After updating a record using a rowedittemplate, the grid is reloaded, but loses what rows are expanded and collapsed. I'd like to reload the grid then put it back the way it was before the postback.
Hello Will Larkin,
The ExpandedRows collection contains an array with the ids of the rows you’ve expanded. You can get a reference to the row in the following manner once you get its id:
var row=igtbl_getRowById(rowId);
Once you get the row element you can get its child elements with:
row.getChildRows();
If the child row are not yet loaded to the grid I'd advise you to expand then on the server side ( this.UltraWebGrid1.Rows[0].Expand(false); ) as i previously suggested in one of my previous posts.
Let me know if you need further assistance with this.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support
Thanks Maya! Getting closer to what I need. I could get the top level grouped rows to expand after the postback, but can't iterate through the child rows as they don't exist as rows in the client. Do you know how I can iterate through the child rows to see them and expand them? In my screenshot in the first post, I can get the New and Pending level to expand, but not the groups below those.
Hello Will Larkin ,
You can easily get the Expanded rows collection from the AfterRowTemplateClose event.For example:
function UltraWebGrid1_AfterRowTemplateCloseHandler(gridName, rowId, bSaveChanges){
//Add code to handle your event here.
var grid = igtbl_getGridById(gridName);
var expRows = grid.ExpandedRows;
}
And on initialize you can attempt to expand the same rows. Please refer to the attached sample.
You can set it also in the UpdateRow event for example with:
this.UltraWebGrid1.Rows[0].Expand(false);
Let me know if you require further assistance.
Maya,
Is there anyway to save what rows are expanded at the end of a AfterRowTemplateCloseHandler client event and then I could apply it back to the grid after the postback? That would keep me from having to delete and insert rows on the client side prior to updating the database.
Thanks Maya! I believe my issue is because I'm databinding again on row update on the server side and that's refreshing the grid. If I comment out the databind in the UpdateRow event then the grid state persists, but I have to rebind because after a row is completely updated it needs to be removed from the grid. I'm going to look into maybe trying to remove the row on the client side, so I don't have to rebind and the row won't show up. I attached my files of the screenshot in my first post in case you have any ideas.