Author Topic: problem when use editCell  (Read 4192 times)

lsl

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
problem when use editCell
« on: September 23, 2014, 03:02:32 pm »
If user edits the grid in the first column column1, I want to go to column3 if column1='3' else  go to column4 after cell save.

I have coded as follows,

cellSave: function( event, ui ) {
   if(ui.rowData["column1']=='3')
      {$grid1.pqGrid( "editCell", { rowIndx: ui.rowIndx, dataIndx: "column3" });}
   else
      {$grid1.pqGrid( "editCell", { rowIndx: ui.rowIndx, dataIndx: "column4" });}
}

When I press tab to next field,it will be only go to column2. I think it went to the column3/column4 but go back to column2.

Does it have a event like "afterCellSave" or any other solution?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6298
    • View Profile
Re: problem when use editCell
« Reply #1 on: September 23, 2014, 11:58:31 pm »
you can do that by setting column.editable = false for column2 and implementing column.editable callback for column3.

In the callback:

When cell in column1 == 3 then return true

else

return false

lsl

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Re: problem when use editCell
« Reply #2 on: September 24, 2014, 07:50:58 am »
I have changed the coding as follows,

cellSave: function( event, ui ) {
   if(ui.rowData["column1']=='3')
   {
    var colM=$grid1.pqGrid( "option" , "colModel" );   
    colM[2].editable = false;
    $grid1.pqGrid( "option", "colModel", colM);             
    var rowIndx = ui.rowIndx;         
   $grid1.pqGrid( "refreshCell", { rowIndx: rowIndx, dataIndx: "column2" } );
   }
}


When I tab out the column1, it will go  to column2. But if I tab to the column3 and then tab back, the column2 is not editable and go to column1.


How to solve this problem?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6298
    • View Profile
Re: problem when use editCell
« Reply #3 on: September 24, 2014, 08:26:21 am »
You can't do this in cellSave event.

Assuming that you want the same behavior for tab forward and tab backward, please modify the colModel as per the steps mentioned in my previous message while initialization of grid ( not in cellSave event )

lsl

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Re: problem when use editCell
« Reply #4 on: September 24, 2014, 10:14:28 am »
Can you give me the sample code about that?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6298
    • View Profile
Re: problem when use editCell
« Reply #5 on: September 26, 2014, 01:04:45 am »