使用clientArray(clientside)进行编辑时,分页对jqgrid的getChangedCells方法有什么影响? [英] What is the effect of paging on jqgrid's getChangedCells method when using clientArray(clientside) for editing?

查看:124
本文介绍了使用clientArray(clientside)进行编辑时,分页对jqgrid的getChangedCells方法有什么影响?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有clientArray选项的jqgrid进行编辑;我的网格正在使用分页;即使在多次更改页面后jqgrid的getChangedCells方法是否仍可能返回正确的更改行,并且服务器中的数据可能发生了更改?-例如,如果服务器中有新行可用,现在如果我回滚,该行将出现在我的网格中; 是否存在rowId冲突-新的rowId将指向与新数据可用之前的行不同的行? 我想我总是可以通过自动递增的主键来排序服务器数据吗?

I am using jqgrid with clientArray option for editing;My grid is using paging; Will the jqgrid getChangedCells method return the correct changed rows even after changing pages several times with a possibility of data from the server having changed?- for example if new rows are available from the server that will now appear in my grid if I page back; Wont there be a rowId conflict - the new rowIds will be pointing to different rows from the ones before new data became available? I guess I could always order my server data by the autoincrementing primary key?..

推荐答案

今天在实验中发现;分页(服务器端),jqgrid会清除getChangedCells的结果;我必须创建一个实用程序函数来存储getChangedCells数组,以便它在分页中持久存在. 我正在这样做,所以我可以分别提交所有更改 在jqgrid选项中,我有类似的内容:

found out today on experimenting; paging (server side) a jqgrid clears the result of getChangedCells; I had to create a utility function to store the getChangedCells array so that it persists across paging; Im doing this so I can submit all the changes separately In jqgrid options I have something like:

('#grid').jqgrid({
  ....
  cellEdit:true,
  cellSubmit:'clientArray',
  colModel: [ {...,editable:true,
                   dataInit:function(el){
                     el.autocomplete({...});
                   }...} ... ],
  afterSaveCell:function(){
                $.retainChangesOnPaging();
                 }
  ....

});

,在实用程序keepChangesOnPaging中,我有类似的内容:

and in the utility retainChangesOnPaging I have something like:

(function(){
  var retainedChanges;
  retainedChanges = new Array();
  $.retainChangesOnPaging = function(){
    var changedCells = ('#grid').jqGrid('getChangedCells');
    // loop over changedCells array, removing duplicates if you want to...
      return  retainedChanges.push(/* this is inside the loop; push current value to array*/);
     ....
  }
   $.getRetainedChanges = function(){
     return retainedChanges;
   }
})(jQuery);

然后,当我准备将所有更改提交到服务器时,我调用$ .getRetainedChanges 另一个问题:我使用keepChangesOnPaging的方式正确吗?尽管代码有效,但似乎有些问题-我可以以任何方式使它更好吗?我的封口还好吗?

then when Im ready to submit all changes to server, I call $.getRetainedChanges Another question : is the way I used the retainChangesOnPaging correct? something seems wrong though the code works - can I make it better in any way? are my closures ok?

这篇关于使用clientArray(clientside)进行编辑时,分页对jqgrid的getChangedCells方法有什么影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆