Author Topic: updaterow not showing in grid  (Read 2929 times)

angelahlp

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 51
    • View Profile
updaterow not showing in grid
« on: December 16, 2020, 11:33:04 am »
I am using version 7.5. I am trying to update the rowdata for a row in the grid. This is the code that I'm using but the grid does not change. I tried to use refreshrow, although it does not seem necessary, but it still does not work.

I need to update the row only knowing what the rowdata is. I don't have the rowindex. But I have confirmed that the rowindx is found when I get it from the rowdata provided. The rowdata comes straight from another identical grid.

var userowindx = editorgrid.getRowIndx( {rowData: rowdata} );
editorgrid.updateRow( { rowData: rowdata, rowIndx: userowindx.rowIndx  });

Please tell me why the grid is not updating.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: updaterow not showing in grid
« Reply #1 on: December 16, 2020, 11:44:06 am »
https://paramquery.com/pro/api#method-updateRow

Correct syntax is

Code: [Select]
grid.updateRow( {
    rowIndx: rowIndx,
    newRow: { field: value,... }
});

Also pass checkEditable: false to updateRow method if the row is uneditable.

angelahlp

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 51
    • View Profile
Re: updaterow not showing in grid
« Reply #2 on: December 16, 2020, 12:11:07 pm »
When I change the parameter "rowData" to "newRow" I get an error message - different on all browsers (included below). I tried adding "checkEditable" and it also does not work. It DOES still find the rowindx based on the rowdata input....

Firefox:
Uncaught TypeError: e is undefined
    saveCell (URL)/js/paramquery-7.5.0/pqgrid.min.js:10
    _digestUpdate (URL)/js/paramquery-7.5.0/pqgrid.min.js:11
    _digestData (URL)/js/paramquery-7.5.0/pqgrid.min.js:11
    updateRow (URL)/js/paramquery-7.5.0/pqgrid.min.js:14

Microsoft Edge:
pqgrid.min.js:14 Uncaught TypeError: Cannot read property 'dataType' of undefined
    at e.cUCData.update (pqgrid.min.js:14)
    at t.<computed>.<computed>.a._digestUpdate (pqgrid.min.js:11)
    at t.<computed>.<computed>.a._digestData (pqgrid.min.js:11)
    at t.<computed>.<computed>.n.updateRow (pqgrid.min.js:14)

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: updaterow not showing in grid
« Reply #3 on: December 16, 2020, 12:39:42 pm »
Could you please share a jsfiddle so that I can check your code.

angelahlp

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 51
    • View Profile
Re: updaterow not showing in grid
« Reply #4 on: December 17, 2020, 02:47:04 am »
I'm having trouble getting the grid to display in jsfiddle. For some reason the heights are getting set to 0px or 1px ? Could you send me a starter jsfiddle that has the correct includes? (I can update links to the paramquery files if necessary. Ultimately I'd like to know how I'm supposed to set this up in JSFiddle so that it works.

Essentially I have two grids. Each one is sending grid updates to the other, both receiving these updates as a rowData object. I then need to update the grid based on the rowData sent:

1. Grid One receives an object that contains updated rowData from Grid Two.
    The rowData sent from Grid Two comes from the "change" event which sends ui.updateList[0].rowData to Grid One.
    NOTE: Ultimately, I need to send rowData updates from other sources besides pqgrids. So the rowData that is sent needs to be in a standard format that can be duplicated by other systems.

2. Grid One finds the rowIndx in it's grid for the rowData sent by Grid Two

3.Using that rowIndx and the rowData sent by Grid Two, Grid One updates that row with the rowData that was sent by Grid Two.
that and then updating it

Code that runs when updated rowData is received (sent into function by "change" through newrowdata variable) as described above:
var userowindx = editorgrid.getRowIndx( {rowData: newrowdata} ); 
editorgrid.updateRow( { rowData: newrowdata, rowIndx: userowindx.rowIndx  });

I've attached the structure of what is being sent as the "newrowdata" (as shown in the console).

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: updaterow not showing in grid
« Reply #5 on: December 17, 2020, 06:35:45 am »
rowData or any object or array shouldn't be shared directly between the grids as it would cause unexpected results or errors.

Only the field values of interest should be copied from the rowData.

Starter jsfiddle: https://jsfiddle.net/adr9zy20/
« Last Edit: December 17, 2020, 06:50:58 am by paramvir »

angelahlp

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 51
    • View Profile
Re: updaterow not showing in grid
« Reply #6 on: December 18, 2020, 12:24:14 am »
I need to update the rows from other sources, not just grids. Can you tell me how I need to format the rowData so that it can be used to update a row?