Crud: [Question] Setting column visibility by default

Created on 10 Jul 2018  路  7Comments  路  Source: Laravel-Backpack/CRUD

Is it possible to be able to hide a datatables column by default?

e.g

$this->crud->addColumn([
    'name' => 'phone',
    'hidden' => true,
]);

So then the column is still loaded in, but it is hidden - then you can use the column visibility to show it if needed?

question

All 7 comments

Not that I know of, no...

Would be nice, but I bet it'll be difficult like hell, because of datatables-responsive and datatable-colvis incompatibility...

Well I believe you know my stance on the data tables responsive front :D

I'm sure we can come up with a solution for those who do not want to poison their eyes with collapsed tables :D

My suggestion as talking on gitter :P with the new release of disabling responsive tables we can add in colvis if responsive tables are disabled. 2 for 1 special?

@OwenMelbz I know, I know :-)

But I personally think the collapsible columns + "..." buttons combo is great. So far the end-users I've questioned are impressed. Well not impressed, but, you know... they thought "_oh but isn't that how it's supposed to work?_". I think that's as close to a compliment as it gets :-)

@OwenMelbz I tried this once, but never got it to work: https://datatables.net/extensions/buttons/examples/column_visibility/columns.html

Just finished the PR for this here https://github.com/Laravel-Backpack/CRUD/pull/1703 - I think it adds a lot of flexibility, having different:

  • visibleInTable
  • visibleInExport
  • visibleInModal
    options for each column.

I can confirm you can just toggle visibleInTable to false for a column, and then it won't show up in the table, BUT it will still be searchable. So - 2 birds with one stone :-)

Great! thanks!

Was this page helpful?
0 / 5 - 0 ratings