Author Topic: Error when commit is called  (Read 1979 times)

groupXS

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 9
    • View Profile
Error when commit is called
« on: January 31, 2018, 05:44:29 pm »
Hi,

I have an issue when creating new items in a grid. When I create new item in a grid and after response from server I call
grid.commit({ type: 'add', rows: changes.addList });
I am getting java script error

jsnlog.js:648 window.onerror logger: {"stack":"TypeError: Cannot read property 'dataIndx' of undefined\n    at l.saveCell (http://localhost:51125/Scripts/lib/paramquery/pqgrid.min.js:9:30945)\n    at t.(anonymous function).(anonymous function).l._digestUpdate (http://localhost:51125/Scripts/lib/paramquery/pqgrid.min.js:10:22122)\n    at t.(anonymous function).(anonymous function).l._digestData (http://localhost:51125/Scripts/lib/paramquery/pqgrid.min.js:10:21735)\n    at e.cUCData.commit (http://localhost:51125/Scripts/lib/paramquery/pqgrid.min.js:13:13131)\n    at t.(anonymous function).(anonymous function).n.commit (http://localhost:51125/Scripts/lib/paramquery/pqgrid.min.js:13:19130)\n    at Object.onSuccess (http://localhost:51125/App/services/custombindings.js:1105:38)\n    at AnonymousObserver._onNext (http://localhost:51125/App/components/limitIntervalsEdit/limitIntervalsEdit.js:167:28)\n    at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.next (http://localhost:51125/Scripts/lib/RxJS/rx.all.js:1828:18)\n    at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext (http://localhost:51125/Scripts/lib/RxJS/rx.all.js:1762:37)\n    at AnonymousObserver.tryCatcher (http://localhost:51125/Scripts/lib/RxJS/rx.all.js:63:39)","message":"Cannot read property 'dataIndx' of undefined","name":"TypeError","logData":"window.onerror Error: Uncaught TypeError: Cannot read property 'dataIndx' of undefined\nurl: http://localhost:51125/Scripts/lib/RxJS/rx.all.js\nline #: 77"} : (http://localhost:51125/Scripts/lib/paramquery/pqgrid.min.js:10:21735)

what is a structure of rows in commit method?
Server side is creating new items and set ids. I set new ids to grid.getChanges().addList and try to use this in commit

In case I do not add anything and call
grid.commit({ type: 'add', rows: changes.addList });
grid.commit({ type: 'update', rows: changes.updateList });
grid.commit({ type: 'delete', rows: changes.deleteList });
everything seems fine (red triangles are gone) or even commit without any parameter
grid.commit();
looks fine, but then ids for newly created items remain empty and after another Accept Changes server side re create them again.

Best Regards

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Error when commit is called
« Reply #1 on: January 31, 2018, 06:52:12 pm »
Structure of rows in commit is similar to the dataModel.data in grid.

Code: [Select]
[
 {field1: value1, field2: value2, ...},
 {field1: value1, field2: value2, ...}
]

The error could be due to incorrect structure of rows or incorrect field names ( dataIndx ) in rows.

If the error still remains unresolved, then please share a plnkr / jsfiddle.

https://plnkr.co/edit/uk1MDOD76SZnTaKBkG0Q?p=preview

groupXS

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Error when commit is called
« Reply #2 on: February 02, 2018, 02:45:07 pm »
Hi,

Thank you for your answer.
I managed to fix it by myself. I start debugging this morning and realized that I have to specify column ID in colModel and I did not.