2

I have the following WebGrid column inside my asp.net mvc web application :-

gridcolumns.Add(new WebGridColumn() { ColumnName ="Description",Header = Html.DisplayNameFor(model => model.Content.FirstOrDefault().Description).ToString(),CanSort=true
,
    Format = @<text>@item.TrimmedDescription</text>});

my question is how i can add hidden-sm bootstrap class to the above column, so that the column will be hidden on small devices ? can anyone advice ?

Thanks

EDIT

i define the Style as follow:-

gridcolumns.Add(new WebGridColumn() { ColumnName ="Description",Header = Html.DisplayNameFor(model => model.Content.FirstOrDefault().Description).ToString(),CanSort=true
,
    Format = @<text>@item.TrimmedDescription</text>,Style="hidden-sm"});
var grid = new WebGrid(
                        canPage: true,
                        rowsPerPage: Model.PageSize,
                        canSort: true,
                        ajaxUpdateContainerId: "skillgrid", fieldNamePrefix: "skill");

            grid.Bind(Model.Content, rowCount: Model.TotalRecords, autoSortAndPage: false);
            grid.Pager(WebGridPagerModes.All);

            @grid.GetHtml(htmlAttributes: new { id = "skillgrid" },   // id for ajaxUpdateContainerId parameter
            fillEmptyRows: false,
            tableStyle: "table table-bordered table-hover",
            mode: WebGridPagerModes.All,
            columns: gridcolumns

            );

the above have removed the Description column on small devices ,, but the grid header is still showing "Description" . so now i got wrong overlap between WebGrid headers and WebGrid columns content...

1 Answer 1

2

It has a style property, you have to just set that property of WebGridColumn properties:

style: "yourcssclass"

or:

style = "yourcssclass"
Sign up to request clarification or add additional context in comments.

6 Comments

so i can add a css class inside the style , something such as style: "hidden-sm" ???
This have removed the column content on small devices, but the column header is still showing ,, can you please check my edit inside my original question ?
You have to add class on header as well
does the WebGrid support defining Style for the header ?
I dont know about that @john G sorry for that
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.