3

Lets say that you have a kendo.data.DataSource. and you modify a row. and the row has become dirty. and now you want to compare if a specific column was changed before you save.

Does kendo.data.DataSource store the old value locally somewhere?

I suspect it does since it seems that you can call .cancelChanges() and .cancelRow() however i cant seem to find it.

I also suspect that you are not supposed to use it.

ColacX
  • 3,928
  • 6
  • 34
  • 36
  • Are you connecting the datasource to a widget like the grid control? If so, there are events in the widget that let you listen for changes. – Rick S Nov 12 '14 at 16:55
  • yes i know however i was thinking i could avoid listening to change events if the old value is already stored somewhere. – ColacX Nov 12 '14 at 17:37

2 Answers2

6

You are correct that you are not suppose to use this, but it is located in the Data Source.

The currently displayed data/dirty data to be submitted is stored in dataSource._data The last saved value/non-dirty data is stored in dataSource._pristineData

The dirty flag is also stored in _data.


In general you don't want to be messing with any variable that begins with the _. You can alternatively save out the current data with the get/set function kendo provides. The dataSource.data() function. Update it with the same function dataSource.data(myNewData)
  • ah. i did notice the _pristineData before, however when i looked, it seemed to contain the same data. – ColacX Nov 12 '14 at 17:41
0

Ideally Kendo will provide such feature. However, the next clean solution I found was by playing with the onfocus and onblure events as following: onfocus: you store original value onblure: you do the logic and put back original if needed.

Best of luck and I hope I helped someone :) If so then cheers my friend :)

Nour Lababidi
  • 414
  • 4
  • 7