Kendo version: ^2019.3.1023
假设我有如下所示的数据源,其中读取支柱被设置为一个函数,返回的数据在剑道格网中使用。
XHR函数/方法的success回调传递一个包含“页面”(作为分页查询结果一部分的对象数组)的对象,以及查询的总结果计数(所有“页面”上记录的计数)。
<script>
var dataSource = new kendo.data.DataSource({
transport: {
read: function(options) {
// make JSONP request to https://demos.telerik.com/kendo-ui/service/products
$.ajax({
url: "https://demos.telerik.com/kendo-ui/service/products",
dataType: "jsonp", // "jsonp" is required for cross-domain requests; use "json" for same-domain requests
success: function(result) {
// notify the data source that the request succeeded
options.success(result);
},
error: function(result) {
// notify the data source that the request failed
options.error(result);
}
});
}
}
});
dataSource.fetch(function() {
console.log(dataSource.view().length); // displays "77"
});
</script>如何设置网格总数?
我尝试在模式中设置它,使用如下所示的TypeScript getter,但这不起作用。
{ schema: { total: this.paginatedRecordsCount }}我还在<kendo-datasource>中尝试了<kendo-datasource>,在<kendo-grid>中,the又是TypeScript getter,类似于这个例子,但这没有任何影响(即使我硬编码值也是如此)。
我发现了这种类型的定义,但没有用:
interface DataSourceTransportOptions {
success: (data?: any) => void;
error: (error?: any) => void;
data: any;
}这是运行时的options.success主体:
function(data) {
that._ranges = [];
that.success(data, params);
deferred.resolve();
}发布于 2020-11-25 17:28:52
当total是TypeScript getter时,在schema中设置TypeScript不起作用。
total: this.paginatedRecordsCount事实证明,您可以使用闭包从处理XHR的方法的成功回调(在我的例子中是Axios.post)访问包装器对象(包含Axios.post),以便回调可以通过下面的schema.total属性以网格“可见”的方式更新count支柱。
total: () => this.paginatedRecordsCountWrapper.counthttps://stackoverflow.com/questions/65008503
复制相似问题