制表符:关于实施自定义 sort/paginate/filter/edit 行为的指南
Tabulator: Guidance on implementing custom sort/paginate/filter/edit behavior
我在 Vue.js 支持的 Electron 桌面应用程序中使用 Tabulator。我的应用程序可以查询相当大的数据存储并在 Tabulator table.
中显示结果
我想做的与 ajax 模块基本相同,但我不想调用 AJAX 来获取新数据,而是调用特定的 API。
我从排序开始。当点击header排序时,我想用排序参数调用自定义api,然后return一个排序的数据切片。在 Tabulator 排序模块 api.
中似乎没有 'native' 方法来执行此操作
同样处理分页——只显示约 100 个结果,如果它们分页到下一页,我会调用 API。
实现此目标的最佳方法是什么?
Can/should 我构建自己的模块(从 ajax 模块起草),或者 sort
和 paginate
直接与 ajax 模块集成?
您可以使用 ajaxRequestFunc 回调将现有的 ajax 请求机制替换为您自己的逻辑。有关详细信息,请参阅 Loading Data, Ajax Documentation
下面的示例显示了一个新函数 queryRealm 用于替换内置 ajax 功能。
该函数将被传递一个 url 和 config 和 params 对象,它们将包含排序、过滤和分页数据,并且应该 return 一个用 [=29] 数组解析的承诺=]数据
function queryRealm(url, config, params){
//url - the url of the request
//config - the ajaxConfig object
//params - the ajaxParams object
//return promise
return new Promise(function(resolve, reject){
//do some async data retrieval then pass the array of row data back into Tabulator
resolve(data);
//if there is an error call this function and pass the error message or object into it
reject();
});
}
var table = new Tabulator("#example-table", {
ajaxRequestFunc:queryRealm,
});
我在 Vue.js 支持的 Electron 桌面应用程序中使用 Tabulator。我的应用程序可以查询相当大的数据存储并在 Tabulator table.
中显示结果我想做的与 ajax 模块基本相同,但我不想调用 AJAX 来获取新数据,而是调用特定的 API。
我从排序开始。当点击header排序时,我想用排序参数调用自定义api,然后return一个排序的数据切片。在 Tabulator 排序模块 api.
中似乎没有 'native' 方法来执行此操作同样处理分页——只显示约 100 个结果,如果它们分页到下一页,我会调用 API。
实现此目标的最佳方法是什么?
Can/should 我构建自己的模块(从 ajax 模块起草),或者 sort
和 paginate
直接与 ajax 模块集成?
您可以使用 ajaxRequestFunc 回调将现有的 ajax 请求机制替换为您自己的逻辑。有关详细信息,请参阅 Loading Data, Ajax Documentation
下面的示例显示了一个新函数 queryRealm 用于替换内置 ajax 功能。
该函数将被传递一个 url 和 config 和 params 对象,它们将包含排序、过滤和分页数据,并且应该 return 一个用 [=29] 数组解析的承诺=]数据
function queryRealm(url, config, params){
//url - the url of the request
//config - the ajaxConfig object
//params - the ajaxParams object
//return promise
return new Promise(function(resolve, reject){
//do some async data retrieval then pass the array of row data back into Tabulator
resolve(data);
//if there is an error call this function and pass the error message or object into it
reject();
});
}
var table = new Tabulator("#example-table", {
ajaxRequestFunc:queryRealm,
});