Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to hide a SlickGrid column WITHOUT removing it from the "columns" array?

I'd like to hide a column (its an ID column that is unique for each row), but I cannot remove it from the "columns" array because I need that data in the Row when actions are performed on the Row (Selection, Sorting, ect).

After being sorted for example, I need to grab the Rows match them up to the previous styles that they had before, and I can do this with the ID column. I need the data in the row, I just don't want it to be displayed.

Thanks.

like image 926
Kevin Avatar asked Jun 16 '11 14:06

Kevin


2 Answers

The answer is NO, but that is not the answer you are looking for :)

Other than what columns are looking at to grab their data, there is no hard link between them and what your data items look like. You don't have to have a column visible to have an ID on your data item.

like image 151
Tin Avatar answered Sep 21 '22 15:09

Tin


In case anyone is still looking for this, I've found a way... it's not massively elegant but it does work. As Simon, suggested, add the Id column as the last in the grid. Set both the cssClass and headerCssClass to be "display:none !important" and set the width, minWidth and maxWidth column options to 0 as follows:

var columns = [
    { id: "MyColumnId", name: "My Column", field: "MyColumnData", width: 100},
    { id: "Id", name: "Id", field: "Id", width: 0, minWidth: 0, maxWidth: 0, cssClass: "reallyHidden", headerCssClass: "reallyHidden" }
];

and the css is:

.reallyHidden { display: none !important;}

Hope that helps.

like image 27
user2837841 Avatar answered Sep 20 '22 15:09

user2837841