Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide column in dgrid dynamically

Tags:

dojo

dgrid

How to hide complete column in dgrid (gridFromHtml) based on some run time parameter? Lets say if the value of parameter is true I should be able to display some column and if the value is false then I should be able to hide that same column.

like image 534
TechnoCrat Avatar asked Nov 30 '22 14:11

TechnoCrat


1 Answers

Use grid.styleColumn(columnId, css):

var grid = new Grid({
    store: store,
    columns: [
        { id: "artist", label: "Artist", field: "Artist"},
        { id: "name", label: "Song", field: "Name"},
        { id: "gerne", label: "Genre", field: "Genre"}
    ]
}, "grid-placeholder");

// to hide column with id="name"
grid.styleColumn("name", "display: none;");

// to show it
grid.styleColumn("name", "display: table-cell;");
like image 192
phusick Avatar answered Dec 09 '22 21:12

phusick