Author Topic: Update selected row  (Read 3538 times)

shldbapp

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 5
    • View Profile
Update selected row
« on: March 24, 2015, 08:46:52 pm »
I want to update the current selected row with the following function:

Code: [Select]
             
...
change: function (event, x) {

                    var userInput = Data.areas[0].label;
                    var currentRow = ui.rowIndx;
                    console.log(currentRow);
                    $grid.pqGrid("updateRow", { rowIndx: currentRow, row: { 'Area': userInput } });
                    $grid.pqGrid("refreshRow", { rowIndx: currentRow });
                }
...

console.log gives me the correct row number, but the function doesn't work. How to solve this?





paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Update selected row
« Reply #1 on: March 24, 2015, 09:20:17 pm »
your code would lead to max call stack exceeded error, updateRow would lead to change event and so on. Provide a custom source parameter as shown in the code below

Code: [Select]
change: function(evt, ui){
                if(ui.source=='ms'){
                   return;
                }
                $(this).pqGrid("updateRow", { rowIndx: rowIndx, row: { 'profits': Math.random() }, source:'ms' });                   
}


http://jsfiddle.net/b6b710mz/69/

shldbapp

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Update selected row
« Reply #2 on: March 24, 2015, 09:48:17 pm »
Thanks for the quick reply!

I updated the code to:

Code: [Select]
                change: function(evt, ui){
                    if(ui.source=='ms'){
                        return;
                    }
                    var userInput = Data.areas[0].label;
                    var current_row = ui.rowIndx;

                    $(this).pqGrid("updateRow", { rowIndx: current_row, row: { 'Area': userInput }, source: 'ms' });
                },

Result:

"Cannot call methods on pqGrid prior to initialization; attempted to call method 'updateRow'"

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Update selected row
« Reply #3 on: March 24, 2015, 10:30:53 pm »
Please provide a small sample of your issue in this jsfiddle.

http://jsfiddle.net/b6b710mz/69/