How to hide column in fuel datagrid

I'm trying to create a hidden column that will contain the unique "id" of the row as an attribute in the word "data identifier". Because I cannot figure out how to get the data model row by row. I am using a server data source.

columns: [{ property: 'hiddencolumn', label: '', hidden: true <-- ????? } .. .. ], 

In formatter I use some placeholder tag, maybe span

 $.each(items, function(index, item) { item.hiddencolumn = '<span data-id="' + item.id + '"</span>'; }); 

then I add a click handler to the row and then get the data id column:

 $('#MyGrid').on('loaded', function() { $('#MyGrid > tbody > tr').click(function() { console.log($(this).find('> td > span').attr('data-id')); }); }); 

It is right? Or should I try to add the data identifier to the tag / line itself? The above concept works, but I just need to know how to hide the column :)

thanks

EDIT April 14th is what I did to solve this problem. Use the data identifier and hide the range in the existing column. For me, I had a "date" and "id" field in my model. I want to mark id in the date field.

 formatter: function(items) { $.each(items, function(index, item) { item.date = item.date + '<span style="visibility: hidden;" data-id="' + item.id + '"/>'; }); } 

Then return the id like this (using jquery)

 $('#MyGrid').on('loaded', function() { $('#MyGrid > tbody > tr').click(function() { console.log($(this).find('> td > span').attr('data-id')); // value is here }); }); 

fine?

+4
source share
1 answer

The columns property is for visible columns only. So it looks like you will want to remove this and in your formatting create a range with the data-id attribute for one of your other (visible) columns. I usually do this in the last column if there are any buttons or other controls to act on the item in the row.

+2
source

All Articles