Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Grid > Strange sorting Behavior
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Strange sorting Behavior

Feed from this thread
  • Fred avatar

    Posted on Jun 27, 2011 (permalink)

    I got this ragrid on a page 
    <telerik:RadScriptManager runat="server"></telerik:RadScriptManager>          
               <telerik:radgrid ID="grdResultats"
                    Width="99%"  OnNeedDataSource="NeedDataSource" AllowPaging="true"
                         AllowMultiRowSelection="false" runat="server" Gridlines="None" AllowSorting="True"
                         AutoGenerateColumns="False" CellSpacing="0"
                               Skin="Default" PageSize="10" >
                       <ClientSettings EnableRowHoverStyle="true">
                       <Selecting AllowRowSelect="True" />
                       </ClientSettings>
                        <MasterTableView Width="100%" Summary="RadGrid table">
                           <Columns>
                              <telerik:GridButtonColumn Visible="False" Text="Select"/>
                       <telerik:GridTemplateColumn  DataField="dem_no" SortExpression="dem_no" HeaderText="No.">
                           <HeaderStyle Width="35px"></HeaderStyle>
                           <ItemTemplate>
                               <%#Eval("dem_no")%>
                           </ItemTemplate>
                       </telerik:GridTemplateColumn>
                       <telerik:GridTemplateColumn>
                           <HeaderStyle HorizontalAlign="Center" Width="20px"></HeaderStyle>
                           <ItemStyle HorizontalAlign="Center"></ItemStyle>
                           <ItemTemplate>
                               <img src='../Images/lum-<%# Eval("pri_cd") %>.gif' border="0">
                           </ItemTemplate>
                       </telerik:GridTemplateColumn>
                       <telerik:GridTemplateColumn SortExpression="dem_titre" HeaderText="Nom" UniqueName="Nom">
                           <ItemTemplate>
                               <%# Eval("dem_titre") %>
                           </ItemTemplate>
                       </telerik:GridTemplateColumn>
                       <telerik:GridTemplateColumn SortExpression="usa_rapporte_prenom" HeaderText="Demandeur" UniqueName="Demandeur">
                           <HeaderStyle Width="110px"></HeaderStyle>
                           <ItemTemplate>
                               <%#Eval("usa_rapporte_prenom").ToString() & " " & Eval("usa_rapporte_nom").ToString()%>
                           </ItemTemplate>
                       </telerik:GridTemplateColumn>
                       <telerik:GridTemplateColumn SortExpression="dem_date_rapporte" HeaderText="Date">
                           <HeaderStyle Width="80px"></HeaderStyle>
                           <ItemTemplate>
                               <%# GDData.Utilitaire.UtilFormaterDate(Eval("dem_date_rapporte"), LangueCd) %>
                           </ItemTemplate>
                       </telerik:GridTemplateColumn>
                       <telerik:GridTemplateColumn SortExpression="usa_assigne_prenom" HeaderText="Assigné à" UniqueName="assigne">
                           <HeaderStyle Width="105px"></HeaderStyle>
                           <ItemTemplate>
                               <%#Eval("usa_assigne_prenom").ToString() & " " & Eval("usa_assigne_nom").ToString()%>
                           </ItemTemplate>
                       </telerik:GridTemplateColumn>
                       <telerik:GridBoundColumn DataField="sta_nom" SortExpression="sta_nom" ReadOnly="True" HeaderText="Statut"/>
                       <telerik:GridBoundColumn DataField="mod_nom" SortExpression="mod_nom" ReadOnly="True" Visible="False"/>
                        </Columns>
                        </MasterTableView>
               </telerik:radgrid>
    I make it sort on the Dem_no column on the click of a button whit this code
    If grdResultats.MasterTableView.SortExpressions.Count = 0 Then
                      Dim expression As GridSortExpression = New GridSortExpression()
                      expression.FieldName = "dem_no"
                      expression.SortOrder = GridSortOrder.Ascending
                      grdResultats.MasterTableView.SortExpressions.AddSortExpression(expression)
                  End If

    But for some reason the sorting dosn't work, the column is grayed like if its was sorted but they no arrow
     indication if its a ascending or descending sorting and the column isn't sorted. The next thing is that when
    I click on a column to be sort its the column to the left that is been sorted. Like if i click on usa_rapporte_prenom
    its dem_titre that is sorted, if i click on dem_titre its dem_no ect... But only for the first sorting after the code above

    Sorry for my english, i'm french :p

    Frédéric

  • Tsvetoslav Tsvetoslav admin's avatar

    Posted on Jun 29, 2011 (permalink)

    Hello Fred,

    If you need to sort the data upon clicking a button outside of the grid then after adding the SortExpression you should call the grid's Rebind() method. In addition, do specify the DataField property for the template columns so that you be able to sort using the column headers.

    Hope it helps.

    Best wishes,
    Tsvetoslav
    the Telerik team

    Consider using RadControls for ASP.NET AJAX (built on top of the ASP.NET AJAX framework) as a replacement for the Telerik ASP.NET Classic controls, See the product support lifecycle here.

  • Fred avatar

    Posted on Jun 29, 2011 (permalink)

    Oups, sorry The code you see is in the page load...

    If grdResultats.MasterTableView.SortExpressions.Count = 0 Then
                      Dim expression As GridSortExpression = New GridSortExpression()
                      expression.FieldName = "dem_no"
                      expression.SortOrder = GridSortOrder.Ascending
                      grdResultats.MasterTableView.SortExpressions.AddSortExpression(expression)
                  End If

    Its like to set the default sorting of the radgrid...

    I try the to add the DataField and that didn't change anything, same thing for the rebind method..

  • Tsvetoslav Tsvetoslav admin's avatar

    Posted on Jul 4, 2011 (permalink)

    Hi Fred,

    Your sort expression code is perfectly all right. Please, open up a formal support ticket and send a test project where the issue is reproduced as there is no indication of any problem whatsoever in the code snippets you have posted. I will debug the project on my side and get back to you with more information.

    Regards,
    Tsvetoslav
    the Telerik team

    Consider using RadControls for ASP.NET AJAX (built on top of the ASP.NET AJAX framework) as a replacement for the Telerik ASP.NET Classic controls, See the product support lifecycle here.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Grid > Strange sorting Behavior