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

Radgrid sorting on checked checkboxes

1 Answer 243 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 30 Dec 2008, 11:42 PM
Hello,

I have two radgrid in which one contains two fields a check box and a name. The system checks what the user has access to and selects the appropiate check box if the user has rights to those feeds. Since there are a lot of feeds I would like the "Selected" checkbox items to appear first. I am unsure on how to do this. Here is my Rad Grid

 

 <telerik:RadGrid ID="RadFeedsList"   
                    DataSourceID="SqlDataSource2"   
                    AllowMultiRowSelection="True" 
                    runat="server"   
                    AllowSorting="True"   
                    GridLines="None"   
                    Width="300px"   
                    CssClass="FeedsList"   
                    AutoGenerateColumns="False" 
                    Skin="">  
                    <MasterTableView Width="100%">  
                        <RowIndicatorColumn> 
                            <HeaderStyle Width="20px"></HeaderStyle> 
                        </RowIndicatorColumn> 
 
                        <ExpandCollapseColumn> 
                            <HeaderStyle Width="20px"></HeaderStyle> 
                        </ExpandCollapseColumn> 
 
                        <Columns> 
                            <telerik:GridClientSelectColumn SortExpression="CategoryID" UniqueName="ClientSelectColumn" ItemStyle-Width="10px" /> 
                            <telerik:GridBoundColumn  DataField="CategoryID" UniqueName="id" Visible="false" HeaderText="Feeds"></telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn  DataField="Name" UniqueName="Name" HeaderText="Feeds"></telerik:GridBoundColumn> 
                        </Columns> 
                    </MasterTableView> 
                    <ClientSettings> 
                        <Selecting EnableDragToSelectRows="true" AllowRowSelect="True"></Selecting> 
                    </ClientSettings> 
                    <SelectedItemStyle CssClass="SelectedItem"></SelectedItemStyle>   
                    <AlternatingItemStyle CssClass="" ></AlternatingItemStyle>  
                </telerik:RadGrid> 

And here is the code that I am trying to get to work:

 GridSortExpression expression = new GridSortExpression();  
            expression.FieldName = "CategoryID";  
            expression.SetSortOrder("Ascending");  
            RadFeedsList.MasterTableView.SortExpressions.AddSortExpression(expression);  
            RadFeedsList.MasterTableView.Rebind();  
 

But it clears all the checkboxes on the rebind/

 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 31 Dec 2008, 05:44 AM
Hi mgaughan,

RadGrid loses its current selection when the data is sorted. You can try following logic in order to persist the selection even after sorting.
Hope the links below will help you to achieve this.
Persisting the selected rows client-side on sorting/paging/filtering/grouping
Persisting the selected rows server-side on sorting/paging/filtering/grouping

Thanks,
Princy.


Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or