Author Topic: Automatic copy values  (Read 2127 times)

joaosales

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 20
    • View Profile
Automatic copy values
« on: February 08, 2018, 05:20:30 pm »
Hi,

Is there a easier way to copy data from one cell to the rest of the cells of columns after, in the same row?
For now i was doing inside the change event. Whenever a value is changed, i get the

ui.updateList and the values at newRow and rowData and copy the value in newRow to the remaining columns at rowData.

and then $grid.pqGrid("updateRow", { 'rowIndx': updatedRowIndx , row: rowData })

Code: [Select]
function UpdateColumns( event, ui ) {
            let changes = ui.updateList[0];
            let rowChange = changes.newRow;
            let newRow = changes.rowData;
           
            //get updated cell and loop at newRow changing the value of the other columns

            this.updateRow({ 'rowIndx': changes.rowIndx , row: newRow });
}

Update the question with the code because it didn't actually work :(

Thanks
« Last Edit: February 08, 2018, 06:25:43 pm by joaosales »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Automatic copy values
« Reply #1 on: February 09, 2018, 10:57:58 am »
You haven't shared full source code or a jsfiddle, I suspect your code would land you into an infinite loop since updateRow() would cause another change event and so on. There is no need to call updateRow if you update rowData in updateList

Code: [Select]
ui.updateList[i].rowData

Alternative ways:

1) use beforeValidate event to make change in newRow and oldRow in ui.updateList

Code: [Select]
ui.updateList[i].newRow
ui.updateList[i].oldRow

2) use copy method of Range object

https://paramquery.com/pro/api#method-Range

3) use of formulas.
« Last Edit: February 09, 2018, 06:13:39 pm by paramquery »