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

RadGrid Sorting Behaviour

3 Answers 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adrian Eng Ying Ming
Top achievements
Rank 1
Adrian Eng Ying Ming asked on 07 Jul 2010, 11:43 AM
Hi,
    i have a scenario where i use the grid inbuilt sorting inbuilt sorting behaviour:
<sortexpressions> 
        <telerik:gridsortexpression fieldname="Sort" sortorder="Ascending" /> 
</sortexpressions> 
i got an undersired behaviour instead of having row sorting from 1- 15, i get 1-10-15- 2-9. as seen in the attached a screen shot.

Regards;
Adrian


3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 07 Jul 2010, 11:55 AM
Hello Adrian,

Could you please elaborate a bit more on the described issue? How are you populating the grid control with data?

Regards,
Pavlina
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
Adrian Eng Ying Ming
Top achievements
Rank 1
answered on 08 Jul 2010, 03:40 AM
hi Pavlina ,
here is the sample code to duplicate the error

        protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
        { 
            RadGrid1.DataSource = Getdata(); 
        } 
 
        private object Getdata() 
        { 
            if (ViewState["Data"] == null
            { 
                DataTable dt = new DataTable(); 
                dt.Columns.Add(new DataColumn("SortOrder")); 
                dt.Columns.Add(new DataColumn("ValueCol")); 
                object[] a; 
                for (int b = 1; b <= 10; b++) 
                { 
                    a = new object[] { b, "Value : " + b }; 
                    dt.Rows.Add(a); 
                } 
                ViewState["DataTable"] = dt; 
            } 
            return ViewState["DataTable"]; 
        } 

       <telerik:radgrid id="RadGrid1" runat="server" onneeddatasource="RadGrid1_NeedDataSource"
            <mastertableview clientdatakeynames="SortOrder, ValueCol"
                <sortexpressions> 
                    <telerik:gridsortexpression fieldname="SortOrder" sortorder="Ascending" /> 
                </sortexpressions> 
            </mastertableview> 
            <clientsettings allowrowsdragdrop="true"
                <selecting allowrowselect="true" enabledragtoselectrows="false" /> 
            </clientsettings> 
        </telerik:radgrid> 

Regards,
Adrian
0
Accepted
Pavlina
Telerik team
answered on 08 Jul 2010, 09:56 AM
Hi Adrian,

Please note that the described behavior is expected when you are sorting string values. To achieve the desired functionality your column could be of type int as demonstrated in the attached project.

I hope this helps.

Best wishes,
Pavlina
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
Tags
Grid
Asked by
Adrian Eng Ying Ming
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Adrian Eng Ying Ming
Top achievements
Rank 1
Share this question
or