MVC 3 Webgrid - how do you hide columns you do not want to be visible?

前端 未结 3 746
[愿得一人]
[愿得一人] 2020-12-05 08:28

I have a webgrid and there is a column I want to be visible only to certain users. Currently I have coded the grid as follows

if (Context.User.IsInRole(Role.         


        
3条回答
  •  离开以前
    2020-12-05 09:08

    Not sure if it can me made more simpler like this by using "columnNames" parameter. I wanted to show "CustomerCode" column so have just put "CustomerCode" any other column gets excluded.

    WebGrid obj = new WebGrid(Custs,columnNames: new[] { "CustomerCode"});
    

    Taken from

    http://www.codeproject.com/Articles/843788/WebGrid-in-ASP-NET-MVC-important-tips#Tip3:-DisplayNecessaryColumnsMVCWebGrid

提交回复
热议问题