gpt4 book ai didi

javascript - 更改 jtable (jquery) 操作选项 RUNTIME

转载 作者:行者123 更新时间:2023-11-29 14:50:40 24 4
gpt4 key购买 nike

我需要在初始化后更改 jtable 的操作选项:

$('#tab-3').jtable({
title: 'Documenti Allegati',
paging: true,
pageSize: 10,
sorting: true,
defaultSorting: 'nomefile ASC',
actions: {
listAction: 'action.php?action=getAllegatiByID&id='+id,
deleteAction: 'action.php?action=delAllegatoByID&id='+id,
updateAction: 'action.php?action=updateAllegatiById&id='+id,
createAction:'temp'
},
fields:{
...
}
...

我需要编辑 createAction url。我试图在 $.hik.jtable.prototype.options 中搜索,但没有找到。

谁能帮帮我?非常感谢

最佳答案

jtable 操作采用 url 或函数,即来自 http://jtable.org/Demo/FunctionsAsActions .

           createAction: function (postData) {
console.log("creating from custom function...");
return $.Deferred(function ($dfd) {
$.ajax({
url: '/Demo/CreateStudent',
type: 'POST',
dataType: 'json',
data: postData,
success: function (data) {
$dfd.resolve(data);
},
error: function () {
$dfd.reject();
}
});
});
},

您可以编写自己的函数来返回:

function myFunc(dfd){
return $.ajax({
url: myCustomUrlThatIwantToChangeDynamically,
type: 'POST',
dataType: 'json',
data: postData,
success: function (data) {
$dfd.resolve(data);
},
error: function () {
$dfd.reject();
}
});
}

所以 Action 可以变成:

createAction: function (postData) {
console.log("creating from custom function...");
return $.Deferred(myfunc($dfd););
},

然后您可以在需要时更改您的网址,createAction 将使用更新后的网址。

只是一个建议。

关于javascript - 更改 jtable (jquery) 操作选项 RUNTIME,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26232291/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com