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

Remote datasources and large datasets

9 Answers 661 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Bjarke
Top achievements
Rank 1
Bjarke asked on 19 Jan 2012, 12:42 PM
Does Kendo support remote data sources with the option to affect which data to retrieve? What I have in mind is e.g. using a JSON service that supports paging or some other filtering.

I don't consider manipulating the dataSource.transport.url using javascript and re-reading the remote data source a viable solution.

9 Answers, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 20 Jan 2012, 10:00 AM
Hello,

Indeed, our DataSource supports server paging, filtering, sorting, etc. You may take a look at the following online demo.

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Bjarke
Top achievements
Rank 1
answered on 20 Jan 2012, 10:26 AM
Thank you. I have been searching the documentation without finding it. Did I overlook it somewhere or is only in the demos yet?

I don't see any documentation on the dataSource.serverPaging (etc) properties. Especially I would need some example or documentation on the service requirements needed in order to support Kendo data source server side paging, sorting etc.
0
Accepted
Rosen
Telerik team
answered on 20 Jan 2012, 10:47 AM
Hi,

Information about DataSource configuration options can be found here.

As you know the KendoUI is client-side library, therefore it is not coupled to particular server-side platform. Thus, when the server paging, filtering, sorting or grouping  is enabled, the DataSource will pass those descriptors to the server through the request and will expect server to return the processed data. It is up to the developer to implement the server-side part of the data processing.

Note that parameterMap function can be use to format the DataSource descriptors into more server friendly format.

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Boone
Top achievements
Rank 2
answered on 10 Feb 2012, 10:16 PM
How would the webservice side of things look if using the parameterMap :

       parameterMap
: function(options) {
         
return {
             pageIndex
: options.page,
             size
: options.pageSize,
             orderBy
: convertSort(options.sort)
         
}
       
}
Here is my webservice:

[OperationContract]
        public IEnumerable<Result> GetResultsByPage()
        {
//How do I access the pageIndex, size, and orderBy
}

0
Accepted
Rosen
Telerik team
answered on 13 Feb 2012, 02:41 PM
Hello Boone,

As it seems that you are using WCF services you will need to convert the parameters to JSON, thus the parameterMap should look similar to the following:

parameterMap: function(options) {
   return JSON.stringify({
      pageIndex: options.page,
      size: options.pageSize,
      orderBy: convertSort(options.sort)
   });
}

Regarding the server-side. 

[OperationContract]
public IEnumerable<Result> GetResultsByPage(int pageIndex, int size, /*The type of orderBy depends on the actual structure of the JavaScript object which is passed to the server */)
{
       //How do I access the pageIndex, size, and orderBy
}

As mentioned in the code snippet the type of the orderBy will vary due to the way the sort expressions are serialized by the convertSort function. Thus you may need to recreate the same structure on the server.
Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Boone
Top achievements
Rank 2
answered on 13 Feb 2012, 06:47 PM
Thanks Rosen, although I still can't get it to work. I can receive the index and size but am stumbling on the sort. Here is what I attempted:

JS:
transport: {
    read: {
        url: "/Services/Searching.svc/GetLoadsByCriteria",
        contentType: "application/json; charset=utf-8",
        type: "POST"
    },
    parameterMap: function (options) {
        var object = {};
        object.pageIndex = options.pageIndex;
        object.size = options.size;
 
        var sortingArray = new Array();
        sortingArray.push(new orderByObj(options[0].field, options[0].dir)); //will change this to the convertToSort and have it populate multiple columns later
 
        object.orderBy = sortingArray;
 
        return JSON.stringify(object);
    }
},
pageSize: 10,
serverSorting: true

Web Service:
[OperationContract]
public IEnumerable<Result> GetResultsByPage(GridOptions options)
{
    //options always come back null
}

GridOptions Object:
[DataContract]
public class GridOptions
{
    [DataMember]
    public int pageIndex { get; set; }
    [DataMember]
    public int size { get; set; }
    [DataMember]
    public IEnumerable<GridSort> orderBy { get; set; }
}
 
[DataContract]
public class GridSort
{
    [DataMember]
    public string field { get; set; }
    [DataMember]
    public string dir { get; set; }
}

If I can't put it in a nice clean object like "GridOptions" on the web service side then that is fine. Anymore help would be appreciated. The sorting comes in as options[i].field and options[i].dir.

Thanks
0
Accepted
Boone
Top achievements
Rank 2
answered on 13 Feb 2012, 08:55 PM
AhhHaa got it. I was trying to over complicate it.

parameterMap: function (options) {
  var object = {};
  object.pageIndex = options.page;
  object.size = options.pageSize;
  object.orderBy = options.sort;
  return JSON.stringify({options : object});
}

Thanks
0
Roel
Top achievements
Rank 1
answered on 18 Feb 2012, 12:20 AM
Boone,
Can you share how you do your sorting on the server/remote side? is it generic?

Thanks

Roel
0
Boone
Top achievements
Rank 2
answered on 18 Feb 2012, 03:06 AM
Try this http://www.kendoui.com/forums/ui/grid/how-to-retrieve-sort-parameters.aspx
Tags
Data Source
Asked by
Bjarke
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Bjarke
Top achievements
Rank 1
Boone
Top achievements
Rank 2
Roel
Top achievements
Rank 1
Share this question
or