开发者

jqgrid edit , save and esc

开发者 https://www.devze.com 2023-02-08 08:06 出处:网络
After I edit the cells inside my selected row, when I press Esc or enter my row is saved, and then the row is still being displayed as \"selected\" an when I select it again it\'s changing to a regula

After I edit the cells inside my selected row, when I press Esc or enter my row is saved, and then the row is still being displayed as "selected" an when I select it again it's changing to a regular row.

My problem is if I choose this 开发者_开发技巧row again it's not displayed in edit mode. It's displayed as selected, and until I choose another row, only then when I select that row again it will be in edit mode.

How can solve this, so that the saved row will be editable again when selected? (and not after editing another row before)


Ok, I think I found solution. Do you have this snippet of code in your js grid initialization? I bet that yes, becasuse it is in official jqGrid demo:

onSelectRow: function(id)
{
   if(id && id !== lastsel)
   {
      grid.jqGrid( 'restoreRow', lastsel );
      grid.jqGrid( 'editRow', id, true, null, function(){ grid.trigger('reloadGrid');return true; } );
      lastsel = id;
   }
},

If yes, problem is right here. If you want to edit row, which was actually edited, you have to write it something like this:

onSelectRow: function(id)
{
    if(id && id !== lastsel)
    {
        grid.jqGrid( 'restoreRow', lastsel );
        grid.jqGrid( 'editRow', id, true, null, function(){ grid.trigger('reloadGrid');return true; } );
        lastsel = id;
    }
    else if(id && id === lastsel)
        grid.jqGrid( 'editRow', id, true, null, function(){ grid.trigger('reloadGrid');return true; }  );

or simply change if condition to only if (id) {...} },

0

精彩评论

暂无评论...
验证码 换一张
取 消