mardi 22 mai 2018

How to add IF statements inside of a kendo grid declaration

I am trying to use one view file for two pages, the functionality in the pages is very similar but slightly different, because of this I would like to use the same grid but do an if statement in the data source to check the user role:

.DataSource(datasource => datasource
            .Ajax()
     if (User.IsInRole("Admin")) {
            .Read(read => read.Action(MVC.ControllerName.ActionNames.Read, MVC.Controller.Name).Data("function"))
     } else {
            .Read(read => read.Action(MVC.OtherController.ActionNames.OtherRead, MVC.Controller.Name).Data("function"))
     }

I get a bunch of syntax errors (e.g. ) expected, ; expected).

The grid is declared using @(Html.Kendo().Grid)....

Aucun commentaire:

Enregistrer un commentaire