jqgrid,如何在删除行之前发布字段

时间:2018-08-31 17:30:07

标签: jqgrid

在jqgrid中删除之前,我需要知道如何发送字段,要添加起来很容易,我有一个脚本,但是对于删除却不行。

这里是要添加的示例:

{//add
recreateForm:true,
jqModal:true,
reloadAfterSubmit:true,
savekey: [true,13],
closeOnEscape:true,
closeAfterAdd:true,
height:150,
width:450,
url:"process/jqgridAnaOT.php",
addCaption : "Asigancion de Analista",
      beforeSubmit:function(postdata){
                var dataString = $("#formid").serialize();
                var numReg = document.getElementById('OT').value; 
                var assign = document.getElementById('Siglas').value;
                var txt_open = document.getElementById('txt_open2').value;
 if(txt_open==0){
          jAlert('La orden se encuentra cerrada, No es posible modificar datos',titulo);
                return false;  
    } else { ...

      }   },

如您所见,要添加一个表格,我们可以在其中处理数据, 该功能beforeSubmit允许我们知道表单中的数据,但是,如果不是jqgrid发出的消息,则删除行时该行将不存在于表单中。

2 个答案:

答案 0 :(得分:0)

删除行时会发生类似事件。如果您使用Guriddo jqGrid,则可能需要查看documentation here

答案 1 :(得分:0)

我找到了解决方法

http://www.trirand.com/blog/?page_id=393/help/how-to-send-additional-post-data-when-deleting-a-row#p17185

        $(function(){
             $("#list").jqGrid({
                   colNames:[...],
                   colModel :[...],
                etc...
               });
         $("#list").jqGrid('navGrid','#pager',
        {add:true,edit:false,del:true,search:false,refresh:true},
        {//edit},
        {//add},
        {//del
          code....
        }
        );
        });

在这种方法中,我默认使用jqgrid接口,它使用的最清晰,使用我修改了代码的解决方案,效果很好。

{//del
recreateForm:true,
jqModal:true,
reloadAfterSubmit:true,
savekey: [true,13],
closeOnEscape:true,
closeAfterAdd:true,
height:130,
width:450,
url:'process/jqgridAnaOT.php?pid="<?=$strPid?>"',
onclickSubmit: function(params){
var txt_open = document.getElementById('txt_open2').value;
var gr = jQuery("#list").jqGrid('getGridParam','selrow');
var val = jQuery('#list').jqGrid('getCell',gr,'Siglas');                                        
    if(txt_open==0){
    jAlert('La orden se encuentra cerrada, No es posible modificar datos',titulo);
    return false;  
     }
     else {
           return {Siglas:val};
          }
  } 
}  // fin del 

我希望这段代码对某人有用