jsgrid:在编辑按钮中添加页面加载?

时间:2017-04-24 09:33:19

标签: javascript jsgrid

我想从内联编辑器更改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>

1 个答案:

答案 0 :(得分:2)

我使用弹出窗口,jQuery对话框,但你也可以使用其他类似的东西,比如引导程序对话框。

我将编辑绑定到一行,我的代码类似于:

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

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

然后,在showDialog函数中,在用户保存时,我使用以下命令触发jsGrid的更新方法,然后刷新网格中受影响的行:

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

希望这有帮助。