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
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
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.
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.
Rosen
the Telerik team
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
}
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
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
parameterMap:
function
(options) {
var
object = {};
object.pageIndex = options.page;
object.size = options.pageSize;
object.orderBy = options.sort;
return
JSON.stringify({options : object});
}
Thanks
Can you share how you do your sorting on the server/remote side? is it generic?
Thanks
Roel