This is a migrated thread and some comments may be shown as answers.

Bug with setOptions + empty data

1 Answer 146 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bridge24
Top achievements
Rank 1
Iron
Bridge24 asked on 22 Nov 2018, 09:27 PM

Hi, I think that I found a bug.

I can reproduce it there: 

https://dojo.telerik.com/@foxontherock/EvuWidey

In my app, I need to use "setOptions" sometimes, because I need to change my "columns" collection depending on the data I display.

If I send non-empty data in my setOptions parameter, it looks like they are kept somewhere, they're back later when I try to sort an empty grid.

Steps to reproduct:

1. Initialise with empty data + columns, sortable.
2. Change the dataset, using the kgrid.setOptions(dataSource: {data: [non empty array]})
3. Now, empty the grid with kgrid.dataSource.data([])
4.Click any header to sort the grid.
Surprise!  the original data from step 2 is back!

You can try it easily in my "dojo" sample.

https://dojo.telerik.com/@foxontherock/EvuWidey

For now, what I did is to always use setOptions with empty data, then applying my data after, and it solve my problem. 

But, I take time to mention it to you because I think it's a bug that can happen to someone else.

Thank you

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 26 Nov 2018, 01:25 PM
Hello,

Thanks for the provided sample.

The described behavior is expected. When the dataSource is empty and an operation is executed a read query is triggered. In this very case the grid is using local transport, which fetches the data from the options.data property.

You can test the behavior by setting a single item instead of an empty array and the read query will not trigger.

e.g.

kgrid.dataSource.data([{ id: 1, text: "111" }]);

To avoid this behavior, I would recommend you to continue setting the data to an empty array using the setOptions method.


Regards,
Georgi
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Bridge24
Top achievements
Rank 1
Iron
Answers by
Georgi
Telerik team
Share this question
or