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

Pre-filter function

2 Answers 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jamie
Top achievements
Rank 1
Jamie asked on 25 Jun 2019, 08:06 AM

Couldn't find any similar questions on the forum so hopefully someone can help :)

 

At the moment I have a pre-filter on my grid, which filters a column based on the role of the logged in user.

 

filter: {

           filters: [{ field: "RSM", operator: "contains", value: manager}]
         }

 

This pre-filters the grid when the logged in user is a manager. The issue I'm having is it will always pre-filter the grid even if the logged in user isn't a manager. So although the data itself won't be filtered, it will still appear as if the Manager column is being filtered.

 

https://ibb.co/FX3c6Qb

 

So is it possible to only apply the filter if the current user is a manager only? If it's just a regular user then don't apply the filter. 

 

Thanks as always.

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetomir
Telerik team
answered on 27 Jun 2019, 06:39 AM
Hi Jamie,

If you would like to apply a condition depending on the role of the currently logged user, I suggest that you set the autoBind property of the grid to false. Then, just after the initialization of the grid (in the JavaScript section), check for the role of the user. 

In case the user's role is "Admin", then you would call the filter method of the data source of the grid, passing the desired filter object. In the other case, simply call the read method of the data source. 

Let me know in case further assistance is required.


Kind regards,
Tsvetomir
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.
0
Jamie
Top achievements
Rank 1
answered on 27 Jun 2019, 09:06 AM

Morning Tsvetomir,

 

That's perfect, thank you. Filtering the data source after the grid loads working great.

 

Kind regards,

Jamie

Tags
Grid
Asked by
Jamie
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Jamie
Top achievements
Rank 1
Share this question
or