I wanted to use observable object for my grid, hoping that the performance would be better then what i was getting before.
but i am not sure if it is. I also am confused about the usage.
It seams to be pretty much the same thing.
[I use TypeScript, that's why the code looks a little bit different to pure JS]
When i add a new item.
With the old way i did something like this:
then i changed it to observable object way like this:
Can't see any performance differences.
The weird thing is when i try to edit the items.
In the old way i did this:
i expected not to have to run the grid refresh with the observable object. But it turns out i still had to do it. or it would not show any changes.
The new code loos like this:
so it's basically the same thing.
I don't get what the advantage is here, especially with the editing of the rows.
Am i using it wrong?
but i am not sure if it is. I also am confused about the usage.
It seams to be pretty much the same thing.
[I use TypeScript, that's why the code looks a little bit different to pure JS]
When i add a new item.
With the old way i did something like this:
static gridItems: cGridItem[] = [];gridItems.push(item); var grid = $("#grid").data("kendoGrid");grid.setDataSource(gridItems);grid.dataSource.read();// Define a DataSource static gDataSource = new kendo.data.DataSource({ data: tsDataManager.gridItems }); // Create an observable object. static vm = kendo.observable({ items: tsDataManager.gDataSource });tsDataManager.gDataSource.add(item);The weird thing is when i try to edit the items.
In the old way i did this:
var grid = $("#vmGrid").data("kendoGrid");var item = grid.dataSource.get(id);item.TimeStamp = tStamp; item.Close = aInfo.Last; item.Price = aInfo.Last; item.NetChange = aInfo.Net; item.AskPrice = aInfo.AskPrice; item.AskSize = aInfo.AskSize; item.BidPrice = aInfo.BidPrice; item.BidSize = aInfo.BidSize; item.TotalVolume = aInfo.Volume;grid.refresh();The new code loos like this:
var grid = $("#vmGrid").data("kendoGrid");var item = tsDataManager.gDataSource.get(id); item.TimeStamp = tStamp; item.Close = aInfo.Last; item.Price = aInfo.Last; item.NetChange = aInfo.Net; item.AskPrice = aInfo.AskPrice; item.AskSize = aInfo.AskSize; item.BidPrice = aInfo.BidPrice; item.BidSize = aInfo.BidSize; item.TotalVolume = aInfo.Volume;grid.refresh();I don't get what the advantage is here, especially with the editing of the rows.
Am i using it wrong?