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

Selectable GridGroupHeaderItem

2 Answers 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Indira
Top achievements
Rank 1
Indira asked on 07 Jul 2010, 09:12 PM
Hi,

I have a specific need to make the GridGroupHeaderItem to be selectable and should be able to handle the selection change too.  I appreciate any help with example.  Also how to embedd image in the GridGroupHeader?

Thanks,
Indira

2 Answers, 1 is accepted

Sort by
0
Accepted
Veli
Telerik team
answered on 08 Jul 2010, 02:32 PM
Hi Indira,

The GridGroupHeaderItem does not support selection. You need to add a CheckBox control inside the item and use its CheckedChange event on the server to notify the selection has changed. You can also add an Image or any other server control to the GridGroupHeaderItem. Simply use RadGrid's ItemCreated and ItemDataBound events to add one and the same control in both. The reason we do that:

1. We use ItemCreated to create the controls on every postback. ItemCreated is fired for every grid item on every postback, so it is ideal for dynamically creating controls inside.

2. ItemDataBound fires when the data items have been databound. Even though this event does not fire on every postback, the table cells clear their dynamic controls when they databind. Therefore, we need ItemDataBound to recreate these lost dynamic controls when the items bind. Only ItemCreated is not sufficient, because ItemCreated fires before the cells are databound and we lose all dynamic controls created in ItemCreated when the cells bind.

To demonstrate this approach I have attached a small test page. It shows how you can add both a CheckBox control to keep track of the selected group header items as well as a custom image in the same dynamic way.

Kind regards,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Indira
Top achievements
Rank 1
answered on 08 Jul 2010, 05:11 PM
Hi Veli,

Thanks for the sample.  It helped me get going with the required funcitonality.  I have set the DataCell.Text to empty and added the Linkbutton in place of check box and wired up the on click event (you could set the commandname to handle in the ItemCommand event itself). So now all the group headers are clickable.  Please keep me posted if the group header can be selectable in the future.

Thanks,
Indira.
Tags
Grid
Asked by
Indira
Top achievements
Rank 1
Answers by
Veli
Telerik team
Indira
Top achievements
Rank 1
Share this question
or