1
votes

iam using kendo ui for MVC and iam trying to build dynamic

table (each time others columns will show)

can u please tell me if its possible to populate grid columns only with certain conditions

something like this :

   columns.Bound(c => c.a).Title(ViewBag.SearchBy+" id").HtmlAttributes(new { @class = "search_by_id" });
            columns.Bound(c => c.b);
if(1>0)
{
            columns.Bound(c => c.c).Title("Conversions");
            columns.Bound(c => c.d).Title("Conversion rate").Format("{0:p1}"); ;
}

thank u

1
what you trying to do here hide whole column or just the cell value..?? - Shaz

1 Answers

1
votes

You can easily use an if statement when creating columns:

if (someCondition)
{
   columns.Bound(c => c.c).Title("Conversions");
}
else
{
   columns.Bound(c => c.d).Title("Conversion rate").Format("{0:p1}");
}