从视图模型调用web api方法并获得每次点击10条记录。我想分页为剑道模板。
这是我的代码:
//这是web api方法,每次调用可获得10条记录
function WebApiMethod(parameter)
{
var url = webApiUrl + 'api/{controller}/{methodname}';
var success = function(result)
{
}
CallWebApi(url, 'POST', success, parameter);
}
///这是从webapimethod
调用的ajax调用function CallWebApi(url, type, successCallBack, data) {
jQuery.support.cors = true;
$.ajax({
cache: false,
type: type,
url: url,
data: JSON.stringify(data),
async: false,
contentType: 'application/json',
success: successCallBack,
error: function (xhr, err) {
}
});
}
///这是与数据源相关的剑道寻呼机
function KendoPager()
{
var pager = $("#pager").kendoPager({
dataSource: ViewModels["NameOfVM"].dataSource,
info: false,
change: function () {
ViewModels["NameOfVM"].pageIndex = pager.page();
}
}).data("kendoPager");
}
//这是绑定到kendopager的数据源
dataSource: new kendo.data.DataSource({
serverPaging:true,
pageSize:10,
})
提前致谢。