JqGrid close dialog when saving

0

Hi, I have the problem that I do not know how to tell my Jquery dialog to close when I save, I use the jquery edit dialog in the following way.

        ondblClickRow: function(rowid){
         jQuery(this).jqGrid('editGridRow',rowid);
         },

What it does is that double-clicking on the row opens the Jquery dialog with the input that has the option of editable: true and sends all the data when I save it and it makes everything perfect, but when I give it save and it ends, the dialog is not closed and I do not know how it was reading that it has this property: closeAfterEdit: true but I do not know how to indicate it, I put it in the code where I create my Grid but it did not work.

Here my complete code

  jQuery("#tbl_mat_puesto").jqGrid({
    url:"select_mat_puesto.php?id_puesto="+id,
    datatype: 'json',
    type:'POST',
    colNames:['ID','Puesto','Clase','Insumo','Clave','Cantidad','UMED','PRECIO HIST'],
    colModel:[
        {name:'id',index:'id',align:'left',key:true,width:80,hidden:false},
        {name:'puesto_m',index:'puesto_m',align:'left',width:50},
        {name:'clase_m',index:'clase_m',align:'left',width:80,search:true},
        {name:'insumo_m',index:'insumo_m',align:'left',width:50},
        {name:'clave_m',index:'clave_m',align:'left',sortable:true,editable:false,width:80,search:true},
        {name:'cantidad',index:'cantidad',align:'right',sortable:true,editable:false,width:10,search:true,editable:true},
        {name:'umed',index:'umed',align:'left',sortable:true,editable:false,width:15,search:true},
        {name:'precio_hist',index:'precio_hist',align:'right',sortable:true,editable:false,width:20,search:false}
    ],
    rownumbers:true,
    rowNum:100,
    rowList:[100,200,500,1000],
    toppager:true,
    sortname:'',
    sortorder:'asc',
    viewrecords:true,
    caption:'Materiales por puesto',
    height: 250,
    width: 950,
    rownumbers: true,
    multiselect:false,
    loadonce: true,
    ignoreCase: true,
    closeAfterEdit:true, 
    editurl:'aumenta_cantidad.php?id_puesto='+id,
    loadComplete:function(){
        // $('.infoidse').parents('td').css('background-color','rgba(222,234,255,1);');
    },
    afterInsertRow: function (){
    },
    ondblClickRow: function(rowid){
      jQuery(this).jqGrid('editGridRow',rowid);
    },

});
    
asked by M. Gress 15.03.2017 в 18:23
source

1 answer

1

I think your jqGrid is missing a method afterSubmit

The imprint of afterSubmit is ( according to the wiki from jqgrid )

afterSubmit : function(response, postdata) 
{ 
… 
return [success,message,new_id] 
}

So declaring that option:

jQuery("#tbl_mat_puesto").jqGrid({
    ...
    afterInsertRow: function (){
    },
    ondblClickRow: function(rowid){
      jQuery(this).jqGrid('editGridRow',rowid);
    },
    afterSubmit : function(response, postdata) {
      alert('se envió la data');
    }

});

You can execute actions to your liking. For example, you can manually trigger the close of the dialog, either by calling an internal jqGrid method or even by manually triggering the click method on the close button (which would be the least elegant way to do it).

EDIT : This second possibility makes me more suitable.

There is another possibility, and that is that the options to edit a cell or row should not be attached to the main jqGrid object, but to the editGridRow

method

In other words, you should put

ondblClickRow: function(rowid){
   jQuery(this).jqGrid('editGridRow',rowid,{
         closeAfterEdit:true
   });
},
    
answered by 15.03.2017 / 18:46
source