is there any option to have 2 way data binding in Grid dataSource? I tried with [(dataSource)]='data', but if I changed data item, this was not shown in the grid. Also if I edited something in grid, it did not changed in original object.
TSThavasianand Sankaranarayanan Syncfusion Team February 18, 2019 07:17 AM
Greetings from Syncfusion.
Query 1: I tried with [(dataSource)]='data', but if I changed data item, this was not shown in the grid.
We have analyzed your query and In Essential JS2, we have used object reference (Inner property changes does not reflect the control) instead of deep watch to prevent the performance issue. Also to overcome the reported problem, we suggest you to use the below solution.
In such cases, we can enforce change detection, similar to the way followed by OnPush Change detection strategy, by changing the reference using the below simple line.
this.data['CustomerID'] = "SUPRD";
this.data = [...this.data]
Please check below links on more info using OnPush change detection strategy and enforcing change detection with after data change.
I have read the documentation for OnPush and I understand preformance problem if not useing it.
But I have question here. I have background socket, which can get message at any time. Messages are about changed item in grid. So if I would use this.data = [...this.data] , than I would lose curently editing task etc.
TSThavasianand Sankaranarayanan Syncfusion Team February 21, 2019 07:52 AM
Based on your query we suspect that you want to do CRUD operations in Grid. By default, if you are using CRUD operation in Grid then we need to have isPrimaryKey column, which has the unique value. So, we suggest you to set the isPrimaryKey for particular column in Grid.
Please let us know if you need further assistance on this.
MAMarkoFebruary 21, 2019 08:30 AM
I have checked edit documentation and adding primaryKey solves the problem with jumping tasks, but I still wonder how to update shown data in grid without to effect on selected or edited task.
So as I said, I have async events, which can at any time update some data in my data array. I would like to update the display of that data in grid, without losing selected row or row data, that are just in editing mode. Beacue now, with this.data = [...this.data] I lose selected or edited row.
Is there a way to achieve this?
TSThavasianand Sankaranarayanan Syncfusion Team February 25, 2019 08:22 AM
Query 1: How to update the row without select and not move to edit form.
We can achieve your requirement by using the updateRow method of Grid.
Query 2: Selected row is not maintained when we update through this.data =[..this.data]
We can achieve your requirement by using selectRow method of Grid. We need to get the rowIndex of those Grid before we start update the data through onPush changes and by using the selectRow method we can select the record after the data get refreshed in Grid.