i use below code invoke web api data, how send pagesize, skip web api.
$scope.consulationworklist = { datasource: new kendo.data.datasource({ schema: { data: "consultationitems", total: "count" }, serverpaging: true, transport: { read: function (options) { $.ajax({ url: "http://localhost:61274/api/v1/consultation/search/result", datatype: "json", success: function (result) { options.success(result); }, error: function (result) { options.error(result); } }); } }, pagesize: 2, }), pageable: { refresh: true, //pagesizes: true, buttoncount: 5, input: true }, scrollable: true, filterable: true, sortable: true, columnmenu: true, resizable: true, };
asp.net web api code:
[httpget] [route("search/result")] public ihttpactionresult simplesearch(int pagesize, int skip) { ienumerable<consultationitemdto> result = _consultationservice.getallconsultationitem(); return ok(new worklistsearchresultdto { count = result.count(), consultationitems = result }); }
there many discussion said kendo send pagesize , skip when setting serverpaging true. not works. 1 can ?
as per approach used parameter map attribute stringify parameters can accept 1 dto on webapi:
transport: { read: { url: svcsampleurl, contenttype: "application/json; charset=utf-8", type: "post", datatype: "json" }, parametermap: function (options) { return kendo.stringify(options); //contains take, skip, sort, , filters } },
and accepted dto @ server end:
public class searchdto { public int take { get; set; } public int skip { get; set; } public list<sortcriteria> sort { get; set; } public list<filtercriteria> filter { get; set; } } public class sortcriteria { public string field { get; set; } public string dir { get; set; } } public class filtercriteria { public string field { get; set; } public string operator { get; set; } public string value { get; set; } }
my webapi method looked this:
[httppost] [actionname("getitems")] public sampleresponse getitems(searchdto searchdto) { //calling different layer read operation based in parameter values return businesslayer.getitems(searchdto); }
Comments
Post a Comment