Avatar of mainrotor
mainrotor
 asked on

I need help using viewbag value to hide a column in my Kendo UI grid

Hi Experts,
I have an MVC.Net application with C#.Net code behind.
I want to use a Viewbag value to determine if some columns in my Kendo UI grid should be hidden or not.

below is a snippet of the code I was trying to use, but it does not work.
How can I make this work?

columns: [
@if(ViewBag.AllowEdit)
{
        {   
             field: "IPA",
             title: "IPA",
         },
        {
             field: "TEST",
             title: "TEST",
        },
}

Open in new window



Thanks in advance,
mrotor
.NET MVC.NET ProgrammingUI/UXJavaScript* kendo

Avatar of undefined
Last Comment
louisfr

8/22/2022 - Mon
Kelvin McDaniel

Assuming that you have set ViewData[“AllowEdit”] = true; in the controller method that returns the View, this should work. Please explain what makes you say it doesn’t work?
ASKER CERTIFIED SOLUTION
louisfr

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy