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

Figure out the selected row when grouped

2 Answers 56 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kjell
Top achievements
Rank 1
Kjell asked on 25 Apr 2011, 10:46 PM
Hi, I have a grid with a bunch of data in template columns.  When I select a row, details for the row are populated in a reading pane which is not part of the grid in any way.  I have a button in that pane which then applies an action to the selected event, part of that is validating the data which the user has filled out.  If there is data missing then background color on the empty fields in the gridviewrow is changed.  This works great except when the grid is grouped because I can't seem to get the selected row. 

I usually do this:

activerow = (

 

GridViewRow)rgvEvents.ItemContainerGenerator.ContainerFromItem(rgvEvents.SelectedItem);

 


But if any grouping has been done then this returns null.  I have also tried to retrieve the active or selected row based on the reading pane (not really a pane but a grid called GridControls):

activerow = (

 

GridViewRow)rgvEvents.ItemContainerGenerator.ContainerFromItem(GridControls.DataContext);

Either way active row is NULL (only when there is grouping).  Based on some of the other threads I have just read, you guys are pretty aware of this behavior and have recommended work arounds that don't require accessing the controls in the gridviewrow directly.  I'm open to that but the only thing I can think of is using a converter to set the background color of the controls in the grid dynamically but that is going to create a lot of work for me.  Do you have any better ideas?

 

2 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 28 Apr 2011, 11:39 AM
Hi Kjell,

I would recommend you to take a look at our Cell Style Selector and Row Style Selector demos. Style selectors allow you change the appearance of various UI elements based on some condition. 

Hope this helps.


Greetings,
Milan
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
Kjell
Top achievements
Rank 1
answered on 29 Apr 2011, 07:42 PM
Hi Milan,

Thanks, that certainly works for the style stuff.  I should have mentioned I am actually doing a lot more to the row, for example hiding and showing specific controls but rebinding the grid should take care of that.

-Kjell
Tags
GridView
Asked by
Kjell
Top achievements
Rank 1
Answers by
Milan
Telerik team
Kjell
Top achievements
Rank 1
Share this question
or