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

How to Sort the Groups in radGrid at runtime

4 Answers 291 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mukunda
Top achievements
Rank 1
Mukunda asked on 18 May 2010, 02:44 PM
Hello experts,
I have a rad grid with 5 groups each having certain number of items. I can sort the groups ascending or decending using sortexpression.
But my need is that, i want to reorder the groups so that the group which i prefer need to be the first one and the
rest may be in any order. simply to say, i want to set certain group to be the first one in the list of groups at runtime. 

Below is my GridView code, Please help on this its very urgent.

d
<telerik:RadGrid ID="GridView1" AllowSorting="true" runat="server" MasterTableView-GroupLoadMode="Client" GridLines="None" AutoGenerateColumns="False" Skin="Office2007" Width=100%> 
                                                                                             <groupingsettings casesensitive="False"  />      
                                                                                        <MasterTableView GroupsDefaultExpanded="false">                                                                                         
                                                                                            <GroupByExpressions> 
                                                                                                <telerik:GridGroupByExpression> 
                                                                                                    <SelectFields> 
                                                                                                        <telerik:GridGroupByField FieldAlias="Category" FieldName="Category" HeaderValueSeparator=" " HeaderText=" &lt;b&gt;Available : &lt;/b&gt;" FormatString="" ></telerik:GridGroupByField> 
                                                                                                    </SelectFields> 
                                                                                                     
                                                                                                    <GroupByFields> 
                                                                                                        <telerik:GridGroupByField FieldAlias="Category" FieldName="Category" FormatString="" SortOrder="None" HeaderText=""></telerik:GridGroupByField> 
                                                                                                    </GroupByFields> 
                                                                                                </telerik:GridGroupByExpression> 
                                                                                            </GroupByExpressions>                                                                                                                                                                              
                                                                                             
                                                                                         
                                                                                            <RowIndicatorColumn> 
                                                                                                <HeaderStyle Width="20px" /> 
                                                                                            </RowIndicatorColumn> 
                                                                                            <ExpandCollapseColumn > 
                                                                                                <HeaderStyle Width="20px" /> 
                                                                                            </ExpandCollapseColumn> 
                                                                                            <Columns> 
                                                                                                <telerik:GridTemplateColumn  UniqueName="TemplateColumn1" HeaderText="&lt;font color=red&gt; Select&lt;/font&gt;"
                                                                                                <ItemTemplate> 
                                                                                                <asp:CheckBox ID="CheckBox1" AutoPostBack="true" runat="server"/> 
                                                                                                </ItemTemplate> 
                                                                                                    <ItemStyle HorizontalAlign="Left" /> 
                                                                                                </telerik:GridTemplateColumn> 
                                                                                                <telerik:GridTemplateColumn HeaderText="Product" UniqueName="URL"
                                                                                                <ItemTemplate> 
                                                                                                   <href=<%# Eval("URL") %> target="_blank" ><%# Eval("Product_Name")%></a
                                                                                                 
                                                                                                </ItemTemplate> 
                                                                                                </telerik:GridTemplateColumn>                                                                                                 
                                                                                                                                                                                               
                                                                                                <telerik:GridBoundColumn EmptyDataText="&amp;nbsp;" HeaderText="Product" UniqueName="Product_Name" DataField="Product_Name" Visible=False > 
                                                                                                    <ItemStyle HorizontalAlign="Left" /> 
                                                                                                </telerik:GridBoundColumn> 
                                                                                                <telerik:GridBoundColumn EmptyDataText="&amp;nbsp;" HeaderText="Date" UniqueName="Date" DataField="Date"
                                                                                                </telerik:GridBoundColumn> 
                                                                                                <telerik:GridBoundColumn DataField="Resolution" EmptyDataText="&amp;nbsp;" HeaderText="Resolution" 
                                                                                                    UniqueName="Resolution"
                                                                                                    <ItemStyle HorizontalAlign="Left" /> 
                                                                                                </telerik:GridBoundColumn> 
                                                                                                <telerik:GridBoundColumn DataField="Percentage_Coverage" EmptyDataText="&amp;nbsp;" 
                                                                                                    HeaderText="% Coverage" UniqueName="Percentage_Coverage"
                                                                                                    <ItemStyle HorizontalAlign="Left" /> 
                                                                                                </telerik:GridBoundColumn> 
                                                                                                <telerik:GridBoundColumn DataField="Price" EmptyDataText="&amp;nbsp;" HeaderText="Price ($)" 
                                                                                                    UniqueName="Total_Price"
                                                                                                    <ItemStyle HorizontalAlign="Left" /> 
                                                                                                </telerik:GridBoundColumn> 
                                                                                                <telerik:GridBoundColumn DataField="Area" EmptyDataText="&amp;nbsp;" HeaderText="Area" 
                                                                                                    UniqueName="Price" Visible="False"
                                                                                                </telerik:GridBoundColumn> 
                                                                                                <telerik:GridTemplateColumn UniqueName="ViewScene"
                                                                                                <ItemTemplate> 
                                                                                                   <href="javascript:openScenePopup('<%# Eval("SubProduct") %>','<%# Eval("AOI") %>','<%# Eval("View_Scene") %>')"><%# Eval("View_Scene") %></a
                                                                                                 
                                                                                                </ItemTemplate> 
                                                                                                    <ItemStyle HorizontalAlign="Left" /> 
                                                                                                </telerik:GridTemplateColumn> 
                                                                                                 
                                                                                                                                                                                           
                                                                                                 
                                                                                                 
                                                                                                 
                                                                                                <telerik:GridBoundColumn DataField="SubProduct" EmptyDataText="&amp;nbsp;" HeaderText="SubProduct" 
                                                                                                    UniqueName="SubProduct" Visible="False"
                                                                                                </telerik:GridBoundColumn> 
                                                                                                <telerik:GridBoundColumn DataField="Notes" EmptyDataText="&amp;nbsp;" HeaderText="Notes" 
                                                                                                    UniqueName="Notes" Visible="False"
                                                                                                </telerik:GridBoundColumn> 
                                                                                                <telerik:GridBoundColumn DataField="Category" EmptyDataText="&amp;nbsp;" HeaderText="Category" 
                                                                                                    UniqueName="Category" Visible="False"
                                                                                                </telerik:GridBoundColumn> 
                                                                                                 
                                                                                                <telerik:GridTemplateColumn HeaderText="Recommended" UniqueName="Recommended"
                                                                                                <ItemTemplate> 
                                                                                                   <img src=<%# Eval("Recommended")%> width=18 height=18 alt="Recommendation is based on your total Area"
                                                                                                 
                                                                                                </ItemTemplate> 
                                                                                                 <ItemStyle HorizontalAlign="Center"  /> 
                                                                                                </telerik:GridTemplateColumn> 
                                                                                                <telerik:GridBoundColumn DataField="EULA" EmptyDataText="&amp;nbsp;" UniqueName="EULA" Visible="False"
                                                                                                </telerik:GridBoundColumn> 
                                                                                            </Columns> 
                                                                                             
                                                                                        </MasterTableView> 
                                                                                        <FilterMenu EnableTheming="True" Skin="WebBlue"
                                                                                            <CollapseAnimation Duration="200" Type="OutQuint" /> 
                                                                                        </FilterMenu> 
                                                                                        <GroupPanel Text=""
                                                                                        </GroupPanel> 
                                                                                    </telerik:RadGrid> 

4 Answers, 1 is accepted

Sort by
0
Accepted
Yavor
Telerik team
answered on 19 May 2010, 12:51 PM
Hello Mukunda,

When using the grouping functionality of the control, the groups will be in either ascending or descending order. Presently, there is no other alternative for this behavior - for example ordering some items first, and then rendering the rest, since this would break the grouping functionality. The items need to be rendered/ordered in par with the default grouping logic of the grid.
I hope this information helps.

Greetings,
Yavor
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
Mukunda
Top achievements
Rank 1
answered on 19 May 2010, 03:50 PM
hi Yavor,

Thanks for your reply!

I can achieve this by adding some character or symbol like * to take the required to the 
first position in the list of groups.

Cheers!
Mukunda
GIS Application Developer
0
Julio Vides
Top achievements
Rank 1
answered on 21 Jun 2010, 10:58 AM

Hello,

On what event are you adding the special character '*' ? I tried doint this in the prerender and databound events of the gridview, but this did not work.

Thanks,
J
0
Mukunda
Top achievements
Rank 1
answered on 22 Jun 2010, 11:30 AM
hi Julio,

Actually i added the character on page load itself before binding the grid.
While preparing the datatable to bind the gridview i just added the special character to the
field name which needs to be the first one in the group.

Say for eg.
In the GridView code of my previous post, the GroupbyField name is category, so i added
the character to the certain category while preparing the datatable on page_load like

DataRow dr = dt1.NewRow();
if(Category == "sdr["Category"].ToString()"){
 dr["Category"] = "*" + sdr["Category"].ToString();
}
And bind the grid with the datatable, so that the specified group would be the first one.
Hope this helps!

Cheers!
Mukunda
GIS Application Developer
Tags
Grid
Asked by
Mukunda
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Mukunda
Top achievements
Rank 1
Julio Vides
Top achievements
Rank 1
Share this question
or