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

Radgrid sorting for multiple columns

1 Answer 477 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phani
Top achievements
Rank 1
Phani asked on 14 Jan 2014, 02:23 AM
I have 10 columns in my radgrid. In that 8 columns are visible all the time. The two columns are dependent on a radio button selection. If index=0 show 9th column or show 10th column. I am trying to sort these last 2 columns(out of which only 1  visible one time). In the page load the first action i perform is set up the radio button list and then bind the grid. I also make that radiobutton list disabled. So the grid doesnt change. I am able to sort on each and every 8 columns. But this new column (9th or 10th) is not. I tried like this

 Dim expression As GridSortExpression = New GridSortExpression()<br>            expression.FieldName = str(intI)<br>            expression.SortOrder = GridSortOrder.Descending<br>            rgContractHistory.MasterTableView.SortExpressions.AddSortExpression(expression)
for the new column in itemdatabound and/or page_load.But it doesnt work. My columns are of this type
  <telerik:GridTemplateColumn ItemStyle-BorderWidth="0"  HeaderStyle-Font-Bold="true" ItemStyle-HorizontalAlign="Left" UniqueName="CustomerName"<br><span class="Apple-tab-span" style="white-space:pre">                                              </span>ShowSortIcon="false"><br><span class="Apple-tab-span" style="white-space:pre">                                                </span><ItemTemplate><br><span class="Apple-tab-span" style="white-space:pre">                                                    </span><asp:Label ID="lblCustomerOrganization" runat="server" Text='<%# Eval("CustomerOrganization")%>'/><br><span class="Apple-tab-span" style="white-space:pre">                                              </span></ItemTemplate><br><span class="Apple-tab-span" style="white-space:pre">                                           </span></telerik:GridTemplateColumn>
You can see that I have sortexpression mentioned and an Eval mentioned. I did this for all 10 columns. 8 work. 9th/10th doesnt. I removed the sort expression and used the GridSortexpression mentioned above for all 10 columns. Still did not work. What else am I missing?Let me know if you need more info. Thanks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 15 Jan 2014, 08:46 AM
Hi Phani,

When using sorting on GridTemplateColumn,  you need to set appropriate SortExpression values for those columns. The SortExpression value should match the DataField you want to sort on (typically the field a control in the template is bound to).

ASPX:
<telerik:GridTemplateColumn UniqueName="CustomerOrganization" ShowSortIcon="false" DataField="CustomerOrganization" SortExpression="CustomerOrganization". . .>
    <ItemTemplate>
        <asp:Label ID="lblCustomerOrganization" runat="server" Text='<%# Eval("CustomerOrganization")%>' />
    </ItemTemplate>
</telerik:GridTemplateColumn>

Thanks,
Princy
Tags
Grid
Asked by
Phani
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or