gpt4 book ai didi

javascript - jsgrid:将页面加载添加到编辑按钮?

转载 作者:行者123 更新时间:2023-12-01 03:45:42 25 4
gpt4 key购买 nike

我想将 jsgrid 编辑按钮的内置功能从内联编辑器更改为打开另一个页面进行编辑。我不太确定该怎么做。有什么想法可以实现更改默认编辑按钮以加载页面吗?这可能吗?到目前为止我已经:

代码:

<script>
$( document ).ready(function() {
$("#jsGrid").jsGrid({
height: "398px",
width: "100%",
inserting: true,
editing: true,
sorting: true,
paging: true,
autoload: true,
pageSize: 10,
pageButtonCount: 5,
deleteConfirm: "Do you really want to delete your job listing?",
controller: {
loadData: function(filter) {
return $.ajax({
type: "GET",
url: "<?php echo site_url('/job/getjobs/'.$this->session->employer_id); ?>",
data: filter
});
},
insertItem: function(item) {
return $.ajax({
type: "POST",
url: "/clients/",
data: item
});
},
updateItem: function(item) {
return $.ajax({
type: "PUT",
url: "/clients/",
data: item
});
},
deleteItem: function(item) {
return $.ajax({
type: "DELETE",
url: "/clients/",
data: item
});
}
},
fields: [
{ name: "title", title: "Title", type: "text", width: 100 },
{ name: "created_on", title: "Created On", type: "text", width: 100 },
{ name: "salary", title: "Salary", type: "text", width: 100 },
{ name: "is_active", type: "text", title: "Is Active", width: 100 },
{ type: "control" }
]
});
});

</script>

最佳答案

我使用弹出窗口、jQuery 对话框,但您也可以使用其他等效的东西,例如引导对话框。

我将编辑与单击一行绑定(bind)在一起,我的代码如下:

$("#jsGrid").jsGrid({
...
rowClick: function(args) {
showDialog(args.item);
},
...
);

showDialog 是启动弹出窗口的函数。所选行在 args.item 中可用。

然后,在 showDialog 函数中,在用户保存时,我使用以下代码来触发 jsGrid 的更新方法,该方法随后也会刷新网格中受影响的行:

$("#jsGrid").jsGrid("updateItem", updatedItem);

希望这有帮助。

关于javascript - jsgrid:将页面加载添加到编辑按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43584533/

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