How to force dataProxy call in form editing if editurl is set in jqgrid

瘦欲@ 提交于 2019-12-25 08:12:09

问题


jqGrid is defined using code below. editurl is used for inline edit. dataProxy is used to upload images in form edit.

However dataProxy is not called if save button is pressed in form edit. How to force dataProxy to be called or other way to allow to upload images in jqGrid column ?

$grid.jqGrid({
        datatype: "json",
        url: '/GetData',
        editurl: '/Edit',
... 
});


$grid.jqGrid("navGrid", "#grid_toppager", { 
            search:  true,
            del: true,
            add: true,
            view: true,
            edit: true
          }, 

        {
    url: null,
    dataProxy : function(opt, args) { 
      alert('Why this box does not appear on form save if jqgrid editurl is set'); 
      },

    beforeInitData: function () {
       var
         colm = $grid.jqGrid('getColProp', '_image'),
         selRowId = $grid.jqGrid('getGridParam', 'selrow');
      colm.editoptions.src = '/GetImage?id=' + selRowId;

    },
   closeAfterEdit: true,
   reloadAfterSubmit: true,
}
);

回答1:


You don't describe the goal of the usage of dataProxy, but if you really need to use the feature you should bu following:

  • you should define dataProxy as callback of jqGrid. You can use $.extend to change $.jgrid.defaults.
  • either url for Add/Edit or Delete operation should be null or you should set useDataProxy option of editGridRow or delGridRow to true explicitly (for example to overwrite editurl which are not null).

So in your case you should just move dataProxy from the list of Edit dialog to the list of jqGrid options.



来源:https://stackoverflow.com/questions/10473879/how-to-force-dataproxy-call-in-form-editing-if-editurl-is-set-in-jqgrid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!