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

[Solved] Persist row selection on postback

1 Answer 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 07 Jul 2014, 07:02 PM
Hi,

I have a parent and child grid that are both using Ajax to when a selection is made on the parent grid to update the child grid. When I select an item on the parent grid, the CSS style for the .rgSelectedRow disappears and is the user has no way of knowing which one they selected although the child grid displays the correct data. I've narrowed it down to the RadGrid1_OnItemDataBound method where I programmatically apply CSS rules to the respective alternating items and regular items. The way I apply the CSS is as follows:

 if (e.Item.ItemType == Telerik.Web.UI.GridItemType.AlternatingItem)
    {
         e.Item.CssClass = " AlternatingItemColor " + cssstyle +  " rgAltRow";
     }
else
    {
         e.Item.CssClass = "rgRow " + cssstyle;
    }

Where cssstyle is the CSS rule based off attributes in the data item. When I remove this code from the method, the selected row persists through the postback, but that's where the problem lies. Any suggestions would be very helpful as to why it's being overridden.

Thanks,

Joe

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 10 Jul 2014, 02:38 PM
Hi Joe ,

If I understand you correctly you have dependent grids and the child grid populates based on the selected item in the parent grid. If this is your scenario I tried to replicate the described problem in the following master/detail grid example, but to no avail: 
http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/master-detail/defaultcs.aspx

Please give it a try and see what is the difference in your case.

You can also take a look at this blog post which explains how to override default styles:
http://blogs.telerik.com/aspnet-ajax/posts/08-06-17/how-to-override-styles-in-a-radcontrol-for-asp-net-ajax-embedded-skin.aspx

If this is not the case, please elaborate a bit more what is the exact scenario you have and what is the expected result. Providing a live URL and step by step instructions how to replicate the issue would allow us inspect the page and provide more to the point answer.

Pavlina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Joe
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or