Reputation: 11
I have displayed few column data in view using setColumns method like this:
$this->crud->setColumns([
(['name'=>'expire_date','lable'=>'Expire Date']),
(['name'=>'username','lable'=>'User']),
(['name'=>'prize_id','lable'=>'Prize']), /* New Column(must be hidden by default) */
(['name'=>'gifted_from','lable'=>'Gifted From']) /* New Column(must be hidden by default) */
]);
What I expected to happen:
now in the same list I want to add few more columns to be shown in list view. But by default this columns should be hidden in list view and what I expect that new added hidden columns (in the above list) i can make visible through column visibility
options provided through $this->crud->enableExportButtons();
Is there any way to do this in laravel backpack?
Upvotes: 1
Views: 2020
Reputation: 1366
It's a bit later but you can do 'visibleInTable' => false
for a column you want to hide by default. You'll be able to make it visible in column visibility
options.
For example:
[
'name' => 'email',
'label' => "Username",
'visibleInTable' => false,
],
Upvotes: 0
Reputation:
You would add the fields you want hidden to the hidden
property on the model:
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = ['attribute'];
Then you can temporarily make fields visible by calling the makeVisible
method:
$user->makeVisible('attribute')
See the docs on Serialization
Upvotes: 2