I am not quite sure why my question got down voted, as I thought it was a pretty simple problem (which could even be answered by a yes or no). So i thought it didn't need a lot of explanation. but nonetheless here's my answer:
There is no option to hide a certain column from the index view of a module in the backend options
If you still want to remove a column from the index view of a module you will need to do 2 things.
- unset the data for the column you want to remove in the dynamic ajax request method of your module's controller. (
dtajax()
)
- remove the html table head element for the column in the
index.blade.php
view of the module you're editing
unsetting the data:
find the dtajax() method inside your module's controller, which is usually located in:
app/Http/Controllers/LA/ModuleNameController.php
which looks like this:
public function dtajax()
{
$values = DB::table('moduleName')->select($this->listing_cols)->whereNull('deleted_at');
$out = Datatables::of($values)->make();
$data = $out->getData();
$fields_popup = ModuleFields::getModuleFields('moduleName');
for($i=0; $i < count($data->data); $i++) {
for ($j=0; $j < count($this->listing_cols); $j++) {
$col = $this->listing_cols[$j];
if($fields_popup[$col] != null && starts_with($fields_popup[$col]->popup_vals, "@")) {
$data->data[$i][$j] = ModuleFields::getFieldValue($fields_popup[$col], $data->data[$i][$j]);
}
if($col == $this->view_col) {
$data->data[$i][$j] = '<a href="' . url(config('laraadmin.adminRoute') . '/moduleName/' . $data->data[$i][0]) . '">' . $data->data[$i][$j] . '</a>';
}
//********************
// Remove description data values
if ($col == "description") {
unset($data->data[$i][$j]);
$data->data[$i] = array_values($data->data[$i]);
}
//
//********************
}
...
}
...
}
Here I choose to remove the description values. I have added this into the nested for loop:
//********************
// Remove description data values
if ($col == "description") {
unset($data->data[$i][$j]);
$data->data[$i] = array_values($data->data[$i]);
}
//
//********************
removing the table heads: the table heads can be found inside the index blade file of the module, usually located in: resources/views/la/modulename/index.blade.php
find the foreach loop which iterates over $listing_cols as $col
<tr class="success">
@foreach( $listing_cols as $col )
<th>{{ $module->fields[$col]['label'] or ucfirst($col) }}</th>
@endforeach
@if($show_actions)
<th>Actions</th>
@endif
</tr>
Surround the table head with an if statement that checks if $col != 'columnName'
. So in my case:
<tr class="success">
@foreach( $listing_cols as $col )
@if($col != 'description')
<th>{{ $module->fields[$col]['label'] or ucfirst($col) }}</th>
@endif
@endforeach
@if($show_actions)
<th>Actions</th>
@endif
</tr>
after editing the module's controller and view, a module's listing will turn from this, into this.
As you can see, it frees up a lot of space.