1

我是 jqgrid 的新手,我想在我的网格中添加删除功能。这是我的代码

    jQuery(document).ready(function(){ 

  jQuery("#list").jqGrid({
  datatype: 'json',

  url:'gridfeeder.jsp?zxc=0',
//  editurl:'gridedit.jsp',
  mtype: "POST",      
  colNames: ['Date', 'Account ', 'Amount', 'Code'],
  colModel: [
  {name: 'adate', index: 'adate', width: 300, sorttype: 'date', align: 'center',datefmt: 'Y-m-d', formatter: myLinkFormatter, editable:true},
  { name: 'account', index: 'account', width: 300, align: 'center', sorttype: 'string', editable:true },
  { name: 'amount', index: 'amount', width: 300, align: 'center', sorttype: 'float', editable:true},
  { name: 'code', index: 'code', width: 300, align: 'center', sorttype: 'float', editable:true }

  ],

  pager: "#pager",
  rowNum: 500,
  rowList: [500,1000, 2000, 3000,4000],
  sortorder: "desc",
  viewrecords: true,
  gridview: true,
  autoencode: true,
  height:400,
  multiselect:true,
  multiboxonly: true,
  loadonce:true,
  caption:"This is me"


  }).navGrid('#pager',

{edit:true,add:true,del:true,search:false,refresh:true},



    {height:280,mtype: "POST",closeAfterEdit: true,reloadAfterSubmit:true, url:'gridedit.jsp',

    afterSubmit: function () {
        $(this).jqGrid("setGridParam", {datatype: 'json'});
        return [true];
    }

},

{height:280,mtype:"POST", closeAfterAdd:true, reloadAfterSubmit:true, url:'gridedit.jsp',

    afterSubmit: function () {
        $(this).jqGrid("setGridParam", {datatype: 'json'});
        return [true, ""];
    }
},

{height:280,closeAfterDel:true, url:'gridedit.jsp',reloadAfterSubmit:true,

    /*delData: {
        name: function() {
                   var sel_id = grid.jqGrid('getGridParam', 'selrow');
                   var value = grid.jqGrid('getCell', sel_id, 'account');
                   alert(value);
                   return value;
              }
       }*/

      onclickSubmit: function (options, rowid) {
          var rowData = jQuery(this).jqGrid('getRowData', rowid);
          return {acc: ret.account};

       },

       afterSubmit: function () {
        $(this).jqGrid('setGridParam', {datatype:'json'});
        return [true,'']; 
    }
}

  );

  function myLinkFormatter(cellvalue, options, rowObject) {

      return "<a href='account094act.jsp?GETDATE=" + cellvalue + "&GETACC=" + rowObject[1] + "'>" + cellvalue + "</a>";
  }

  jQuery("#refresh_list").click(function(){
        jQuery("#list").setGridParam({datatype: 'json'});
        jQuery("#list").trigger("reloadGrid");
    });
}); 

在尝试 delData 部分时,删除操作停止工作。当我点击提交时,没有任何反应。如您所见,我也尝试过使用 onclicksubmit,但在这里我也面临同样的结果。

请帮忙。

谢谢

4

0 回答 0