Need More Info
Last Updated: 08 Feb 2022 09:31 by ADMIN
David
Created on: 13 Oct 2021 16:57
Category: Grid
Type: Feature Request
1
setOptions() Fails when grid has been changed (columns added, removed, changed, ordered, etc)

We are using the functionality included with the grid (mvc and .net core) to save and set filters, sorts and groupbys.  Where the functionality fails is if the grid or columns change in any way (including toolbars).  the getoptions() and setoptions() is a snapshot in time and is not very adaptive.  Our users had 1000's of saved grids and was really not allowing us to change the grid data or columns or even change the default order of the columns.  What we ended up doing to allow the saved grids to work and the developers to have the freedom to change the grids was:

1.  Getting the grid that is passed down to the screen and saving it for a clear functionality (and knowing what the default was supposed to be).

2.  Looking at the sort, groupby and filter subcomponents of the saved grid objects by column and looking for a column match in the grid that was passed to the screen.

3.  If a column in the saved grid does not exist, do not apply those filters, sorts and groupby's and alert the user

4.  Only apply/change the filters, sorts and groupbys via a setOptions() on the grid that is passed down as opposed to a set of the entire object.

6.  If a column is added to the grid alert the user that the column is added

7.  If the grid has changed, use a getOptions() to resave the users selections with the modifications above

8.  Load the data 

 

We have javascript that does the column compare, with differences in the grid if your developers would like to see how we solved this issue. 

4 comments
ADMIN
Maria Ivanova
Posted on: 08 Feb 2022 09:31

Hi David,
A friendly reminder and ask for input (in case the item is still relevant). We will appreciate your comments and input on the item in the coming month. Alternatively, let us know if the case is resolved and we can close it. 

Kind Regards, Maria VeledinovaPM at Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

ADMIN
Georgi Denchev
Posted on: 02 Nov 2021 10:28

Hello, David,

Thank you for the additional details!

I tried reproducing both of the problems, however I was unable to, perhaps there's a difference between our configurations.

Problem 1:

https://dojo.telerik.com/@gdenchev/OteDajUq 

Problem 2:

https://dojo.telerik.com/@gdenchev/ezizAsUL 

In the first Dojo, one of the columns has its field changed before the options are reapplied, however nothing seems to break. In the second Dojo the toolbar is changed before the options are set back but again nothing seems to break.

I also wanted to take a moment and go back the the initial post and more precisely the fourth point.

Only apply/change the filters, sorts and groupbys via a setOptions() on the grid that is passed down as opposed to a set of the entire object.

The setOptions method does not expect the entire object generated by getOptions to be passed down. You can change any of the grid properties one by one as well.

// Change the filterable configuration
grid.setOptions({
    filterable: false
});

// Change the pageable configuration and the Grid columns.
grid.setOptions({
    pageable: true,
    columns: [/*...columns array*/]
});

You may also delete parts of the object created by getOptions() and reapply only some of them. As far as filters, sorts, groups go, these are applied to the dataSource itself, not the Grid. The setOptions method doesn't have relation to these settings, other than the fact that getOptions also saves the dataSource object(which could be excluded when you reapply the settings).

Would you mind updating the Dojos to reproduce the problems you were describing so I can forward them to the Dev team for a review?

Best Regards,
Georgi Denchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

David
Posted on: 26 Oct 2021 16:49

The simple way to break get and set options is to:

1.  Create a grid with bound columns

2.  Use getoptions to persist filters and sorts

3.  Change a bound property in your object

4.  Use setOptions with the persisted data and watch the grid blow up.

 

Or

1.  Create a grid with a toolbar

2.  Use getoptions to persist filters and sorts

3.  Change the toolbar

4.  Use setOptions with the persisted data and watch the toolbar change.

 

I propose using a more robust setoptions alerting the developer to changes in the grid and take the downloaded grid as the source of truth applying the matching columns.

ADMIN
Georgi Denchev
Posted on: 20 Oct 2021 12:28

Hello, David,

Thank you for all of the provided details!

However I am not quite sure what the exact Feature Request is?

Generally speaking there could be certain scenarios where using getOptions and setOptions directly may not be optimal or may not work altogether. In these situations it is best for the Developer to manually set particular configurations, as you have already done.

However these are project specific modifications and while they may work and help some people, they may also cause troubles for others(if they are implemented by default for everyone). That is why getOptions exposes all of the currently applied configurations which you can further modify and then set them back to the Grid via setOptions or some other method.

Could you please elaborate a bit more about the request that you have?

If you wish to share your solution with the rest of the community, we can create a Knowledge Base article which anyone can read.

Best Regards,
Georgi Denchev
Progress Telerik

Remote troubleshooting is now easier with Telerik Fiddler Jam. Get the full context to end-users' issues in just three steps! Start your trial here - https://www.telerik.com/fiddler-jam.