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

Bug with setOptions + empty data

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

Hi, I think that I found a bug.

I can reproduce it there:

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[])
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.

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
Telerik team
answered on 26 Nov 2018, 01:25 PM

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 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.[{ 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.

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.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question