This is a migrated thread and some comments may be shown as answers.

Contolling Group expansion in radGrid

1 Answer 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 24 Jul 2008, 01:41 PM

We have a radGrid with automatic inserts, updates and deletes. We're using a FormTemplate for the insert/edit. When the grid initially loads, we're collapsing all of the group sections. We're also collapsing all of the group sections when the user clicks to "Add new record." so that only the input form is displayed.

How do I prevent expansion of all of the group sections when...
A) The user clicks the "Edit" or "Delete" buttons.

B) After the "Insert" or "Cancel" button is clicked when adding a new record. We actually want to expand only the group section for the inserted record and scroll the display of the grid so that the newly inserted record is visible. 

Essentially regardless of the Insert/Edit/Delete activity, we want the group sections that were collapsed to stay collapsed; those that were expanded to be expanded. Currently all of the group sections expand.

Thanks.

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 25 Jul 2008, 01:59 PM
Hello Scott,

I am attaching a sample page demonstrating the functionality you requested. By default RadGrid keeps its items expanded when working with groups. If you need to keep track of the expanded/collapsed state of the group items, you will need to manage this by yourself. The attached sample demonstrated how an Item is expanded based on a boolean session variable in ItemDataBound, which variable is modified in the ItemCommand event handler, when the command is Expand/Collapse. Using this approach, items expanded states are persisted throughout postacks, data source events, and even beyond page lifecycle (due to session state maintenance).

Implementing expanding of the newly inserted item is not as trivial as it may seem. The reason for this is that RadGrid could not know the newly inserted item's place in the data table beforehand. Therefore, to implement this you need to have some unique identifier for the item to check in the ItemDataBound event. For example, if you know that you have entered an item with unique ID 12, you can check in the ItemDataBound event if the current item has ID 12 and expand its group header.

Sincerely yours,
Veli
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Scott
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or