Kendo UI Jquery 匹配网格中的数据源
我的页面上有一个 Kendo UI 网格,它通过 ajax 调用填充后端 api 的数据源。 我在脚本标签中引入了另一个名为 dataSource 的变量,它从相同的 api 获取数据,并将在多个函数中使用,如下所示:
var dataSource = new kendo.data.DataSource
({
type: "json",
serverPaging: true,
serverSorting: true,
serverFiltering: true,
allowUnsort: true,
pageSize: 10,
group:{field:"Status"},
transport:
{
read:
{
url: window.location.origin + "/api/HL7Message/getListOfProcessedData/",
dataType: "json",
type: "POST",
contentType: "application/json;",
cache: false,
async: false
},
parameterMap: function (options)
{
return JSON.stringify(options);
}
},
serverSorting: true, // server Side sorting by
sort: { field: "ModifiedDate", dir: "desc" }, // Descending Modified Date
batch: true,
schema:
{
model:
{
id: "SampleId",
fields:
{
SampleId: { type: "string" },
Status: { type: "string" },
IsStored: { type: "string" },
CreatedDate : { type:"date"},
ModifiedDate:{type:"date"},
ExceptionMsg: { type: "string" }
}
},
data: "data", total: "total"
}
我想通过获取当前网格中的页码并在页面中使用它来将此数据源同步到我的数据网格财产。
这是我的网格:
$("#grid").kendoGrid({
dataSource: dataSource,
height: 720,
pageable: {
refresh: true,
serverPaging: true,
serverSorting: true,
serverFiltering: true,
},
sortable: true,
filterable: false,
scrollable: false,
navigatable: false,
noRecords: true,
dataBound: onDataBound,
toolbar: [
"Queue Data Status",
{ template: "<button id='RegenerateButton' onclick=regenerateAll()>Regenerate All</button>"} ,
"search"],
columns: [{
field: "sampleId",
title: "Sample Id",
template: "<div class='msg-photo' style='background-image: url(/images/email_material.png);background-size: cover;background-size: 70px 70px'></div><div class='sample-id'>#: sampleId #</div>",
width: 150
},{
field: "createdDate",
title: "Created Date",
template:"<div class='createdDateTemplate'>#= kendo.toString(kendo.parseDate(createdDate), 'dd/MM/yyyy hh:mm tt') #</div>",
width: 150
},{
field: "modifiedDate",
title: "Modified Date",
template:"<div class='modifiedDateTemplate'>#= kendo.toString(kendo.parseDate(modifiedDate), 'dd/MM/yyyy hh:mm tt') #</div>",
width: 150
},{
field: "isStored",
title: "Data Stored In Blob",
template: "<span id='badge_#=sampleId#' class='isStoredBadgeTemplate'></span>",
width: 150
}, {
field: "status",
title: "Status Of Data",
template: "<span id='badge_#=sampleId#' class='statusBadgeTemplate'></span>",
width: 150
},{
field: "exceptionMsg",
title: "Exception Message",
width: 150,
sortable: false,
template: "#if(status=='F'){#<div id=badge_#=sampleId# class=exceptionBadgeTemplate>#=exceptionMsg#</div>#} else {##}#",
},{
field: "Retry",
title: "Action",
width: 100,
sortable: false,
template: "#if(status=='F'){#<button class=btn btn-info onclick=regenerateFile(#=sampleId#)>Regenerate</button>#} else {#<button class=btn btn-info disabled>Regenerate</button>#}#"
}],
});
});
我应该怎么做?
或者有更好的方法吗? 编辑:我尝试将变量设置为网格的页面属性并在数据源中使用它,但它不起作用。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试通过 获取网格的当前页面寻呼机字段,提供对附加到网格的寻呼机小部件的引用,它是 页面方法。
You can try getting the current page of the Grid via the pager field, providing reference to the Pager widget attached to the Grid, and it's page method.