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

natural sort on data source field

1 Answer 208 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 25 Mar 2013, 02:15 PM
Is there a way to override or add functionality to the data source so i can add natural sort functionality?  I have a column that has numbers stored as text.  I need it to sort using a natural sort.

I'm using the an ajax data source on a grid.  Where does the sort actually happen, server side or client side?

thanks,
~ Paul

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 27 Mar 2013, 11:56 AM
Hi Paul,

Kendo DataSource supports both client and server side sorting. By default server side sorting is turned off and sorting happens on the client side.

I believe that the problem in your case is connected with the type of the fields which are defined in schema.model.type object. If the field types are not defined explicitly, the DataSource will consider them as strings - this is the reason why numbers are sorted in alphabetical order.

Please check your DataSource configuration, the model should look like:
schema: {
    model: {
        id: "ProductID",
        fields: {
            ProductID: { editable: false, nullable: true },
            ProductName: { type: "string" },
            UnitPrice: { type: "number", validation: { min: 1} }
        }
    }
}

I hope this will help.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or