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

[Solved] Unable to pick Grid default sort order.

3 Answers 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
giridhar
Top achievements
Rank 1
giridhar asked on 04 Feb 2009, 01:56 PM
Hi,
  I have a grid. Fields in the grid allow to sort only in two ways(ascending, descending). But for the first time load I want it to show sorting based on first column. I read an article at http://www.telerik.com/help/aspnet-ajax/grdsortingexpressions.html. This is not working. Below is code sample, do let me know if some thing else needs to be done.

    <rad:RadGrid ID="RegularActGrid" AllowPaging="true"  Skin="Vista" AllowSorting="true" OnPageIndexChanged="RegularActGrid_PageIndexChanged" OnNeedDataSource="RegularActGrid_NeedDataSource" OnSortCommand="RegularActGrid_SortCommand" EnableEmbeddedSkins="false" runat="server" Width="100%" AutoGenerateColumns="False">
          <PagerStyle Visible="false"/>
          <MasterTableView PageSize="10" AllowPaging="true" AllowCustomPaging="true" AllowCustomSorting="true" AllowNaturalSort="false" AllowSorting="true" EnableNoRecordsTemplate="true">
               <NoRecordsTemplate >
                
                </NoRecordsTemplate>
                <SortExpressions>
                    <rad:GridSortExpression FieldName="ActivityName" SortOrder="Ascending" />
                </SortExpressions>
              <Columns>
                  <rad:GridTemplateColumn SortExpression="0" HeaderText="<%$ Resources:L_LMS_Activity_ExceptionDetails, Info_ColEmpName%>" UniqueName="ActivityName">
                  <ItemStyle VerticalAlign="Middle"/>
                  <ItemTemplate>
                    <asp:Label runat="server" ToolTip='<%# GetName(Eval("EmployeeFName"), Eval("EmployeeLName"), Eval("EmployeeMI"))%>' Text='<%# GetName(Eval("EmployeeFName"), Eval("EmployeeLName"), Eval("EmployeeMI"))%>'></asp:Label>
                    
                  </ItemTemplate>
                  </rad:GridTemplateColumn>

                  <rad:GridTemplateColumn SortExpression="1" UniqueName="EmpIdentifier">
                  <ItemStyle/>
                  <ItemTemplate>
                    <asp:Label runat="server" ToolTip='<%# Eval(this.g_strEmpIdentifierRSName)%>' Text='<%# Eval(this.g_strEmpIdentifierRSName)%>'></asp:Label>
                  </ItemTemplate>
                  </rad:GridTemplateColumn>


                  <rad:GridTemplateColumn SortExpression="4" HeaderText="<%$ Resources:L_LMS_Activity_ExceptionDetails, Info_ColAssignment%>" UniqueName="RequiredIncomplete">
                  <ItemStyle/>
                  <ItemTemplate>
                  <asp:Label runat="server" ToolTip='<%# GetColData(Eval(this.g_strCol1),0)%>' Text='<%# GetColData(Eval(this.g_strCol1),0)%>'></asp:Label>
                  </ItemTemplate>
                  </rad:GridTemplateColumn>
                  <rad:GridTemplateColumn SortExpression="2" HeaderText="<%$ Resources:L_LMS_Activity_ExceptionDetails, Info_DueDate%>" UniqueName="RecommendedIncomplete">
                  <ItemStyle/>
                  <ItemTemplate>                
                    <asp:Label runat="server" ToolTip='<%# GetColData(Eval(this.g_strCol2), 1)%>' Text='<%# GetColData(Eval(this.g_strCol2),1)%>'></asp:Label>
                  </ItemTemplate>
                  </rad:GridTemplateColumn>

              </Columns>
          </MasterTableView>
          <ClientSettings>
         <Scrolling AllowScroll="true" EnableVirtualScrollPaging="true" UseStaticHeaders="true" />
          <Selecting AllowRowSelect="True"></Selecting>
         <Resizing AllowColumnResize="true" />
         </ClientSettings>   
        </rad:RadGrid>   

3 Answers, 1 is accepted

Sort by
0
Accepted
Yavor
Telerik team
answered on 09 Feb 2009, 08:34 AM
Hi giridhar,

I tested the described behavior, and the control behaved as expected.
Attached to this message, is the code which I used for testing. Take a look at it and let me know if I am leaving something out.

Kind regards,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
giridhar
Top achievements
Rank 1
answered on 09 Feb 2009, 09:54 AM
Thank you, problem got solved.
0
Fred
Top achievements
Rank 1
answered on 05 Mar 2010, 03:58 PM
I'm having the same issue, what was the fix?  Never mind got it.
Tags
Grid
Asked by
giridhar
Top achievements
Rank 1
Answers by
Yavor
Telerik team
giridhar
Top achievements
Rank 1
Fred
Top achievements
Rank 1
Share this question
or