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

Does grid support true client-side only click sorting of headers?

1 Answer 181 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rik
Top achievements
Rank 1
Rik asked on 15 Aug 2012, 01:39 PM
Updated for clarity:

The client side grid sorting example creates data locally and assigns that data to the kendo grid rather than fetching it via a dataUrl. I am fetching the data initially via a dataUrl and setting all the properties of the dataSource.transport correctly with the autoBind set to true on the grid. After this initial fetch, I want to disconnect and have sorting/paging/filtering occur strictly client side. Is this possible?

I've not been able to get a definitive answer on this from the documentation or via numerous Google searches.  No matter what I set the datasource's serverSorting property to, I get a post to the server which resets my data.  I simply want to sort the data client side, even when it is dirty and not hit the server.    

I have wrapped the kendo grid in our own widget and have added lots of code to add/remove functionality to the kendo grid that we needed (or didn't want).  I can trap the click of the header and do our own sorting of the client data source if I have to, but before I go down that road, I want to make sure that kendo grid does NOT support a true client-side ONLY sorting.  

Thanks in advance for your time,
Rik  

1 Answer, 1 is accepted

Sort by
0
Ryan
Top achievements
Rank 2
answered on 18 Aug 2012, 01:26 AM
Simple answer yes any way you want it. When using a web service for the data.  The setting for client / server sorting is actually in the DataSource. (serverSorting)

Here is a simple example
ds = new kendo.data.DataSource({
    serverSorting: false,
    schema: {
        data: "d.Vehicles",
        model: {
            id: "Ip",
            fields: {
                Name: { type: "string" },
                LastMotion: { type: "date" },
                Hours: { type: "number" }
            }
        }
    },
    transport: {
        read: {
            url: appRoot + 'services/reports/motion.asmx/VehicleLastMotion',
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            type: 'POST'
        },
        parameterMap: function (data, operation) {
            var x = { tags: '{0}'.format(GetSelectorTags().qry) };
            return JSON.stringify(x);
        }
    }
});
 
var grid = $('#summaryTable').kendoGrid({
    filterable: true,
    selectable: 'row',
    pageable: false,
    sortable: {  mode: 'single'},
    columns: [
                { field: 'Name', title: 'Vehicle', width: '*' },
                { field: 'Hours', title: 'Hours', width: '70px' },
                { field: 'LastMotion', title: 'Last Motion', width: '180px', template: '#= kendo.toString(LastMotion,"MM/dd/yyyy hh:mm:ss") #' }
             ],
    dataSource: ds,
    autoBind: false
});
 
Tags
Grid
Asked by
Rik
Top achievements
Rank 1
Answers by
Ryan
Top achievements
Rank 2
Share this question
or