Author Topic: Get row number in Jsonchanges  (Read 3239 times)

cijojohn

  • Pro Ultimate
  • Jr. Member
  • *
  • Posts: 73
    • View Profile
Get row number in Jsonchanges
« on: November 10, 2017, 11:44:11 am »
Hello Team,

I want get row Number in getChanges method. Please suggest on that. Also i want to get row number in sorting also.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6296
    • View Profile
Re: Get row number in Jsonchanges
« Reply #1 on: November 10, 2017, 12:31:11 pm »
row Number can be obtained from rowData reference by getRowIndx method.

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

Please elaborate your question if you have any specific needs.

cijojohn

  • Pro Ultimate
  • Jr. Member
  • *
  • Posts: 73
    • View Profile
Re: Get row number in Jsonchanges
« Reply #2 on: November 10, 2017, 02:18:37 pm »
Actually, i want to send row number along with addlist,updateList on getChanges method. even if we sort and filter.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6296
    • View Profile
Re: Get row number in Jsonchanges
« Reply #3 on: November 10, 2017, 04:40:57 pm »
You need unique row ID to identify rows on server rather than a row number.

For example https://paramquery.com/pro/demos/editing_batch, Product ID is the unique identifier of rows. Product ID is sent along with updated and deleted rows.

row numbers have significance only in the context of grid, it's the index of row in grid. it's not constant and changes when the grid is sorted and filtered, so they don't have significance in the context of server side processing.

Anyway if you still need them, just call getChanges without format parameter.

grid.getChanges(); which returns reference to rowData in addList, updateList and deleteList.

And you can get rowIndx of every row by getRowIndx method.

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

omerix

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 148
    • View Profile
Re: Get row number in Jsonchanges
« Reply #4 on: November 11, 2017, 03:20:57 am »

Hello Team,

I want get row Number in getChanges method. Please suggest on that. Also i want to get row number in sorting also.

I am not sure. It might work.

Code: [Select]
var ri;
var obj;

var gc=grid.getChanges().addList;
$.each(gc,function(index, value){
ri=value.pq_ri;
console.log(ri);
grid.addClass({rowIndx: ri, cls: 'ui-state-error'});
// grid.refreshRow({rowIndx:ri});
})

var gc=grid.getChanges().updateList;
$.each(gc,function(index, value){
ri=value.pq_ri;
console.log(ri);
grid.addClass({rowIndx: ri, cls: 'ui-state-error'});
// grid.refreshRow({rowIndx:ri});
})