laravel-admin
laravel-admin copied to clipboard
Model popup using AJAX to show current contents and icon change
- Laravel Version: 9
- PHP Version: 8.0.9
- Laravel-admin: 1.8.17
Description:
I am using Grid Column Model to load Related Notes, but unfortunately it has 2 issues
- Icon for Column is always Clone icon, there is no way to change it
- All popup data is loaded with page load, how to load it using AJAX on Icon click, so latest records can be shown.
Steps To Reproduce:
`$grid->column('notes', __('Notes'))->display(function ($title, $column) { $notes = $this->notes()->with('admin:id,name')->take(10)->orderBy('id','desc')->get()->map(function ($note) { //return $note->only(['id','description','admin_user_id' , 'created_at']); return [$note->id,nl2br($note->description ."\n\r\n\rBy ".$note->admin->name ." @ ".date("d/m/Y h:i A",strtotime($note->created_at)))]; }); // dd($notes->flatten()->toArray()); // Otherwise it is displayed as editable if(count($notes)>0){ //Show Icon, and show Notes in model popup if count greater than 0 return $column->modal('Latest Notes', function ($column) use($notes) { return new Table(['ID', 'Description'], $notes->toArray(),['table-striped']); //return new Box('No Information', 'There is no note to show'); });
}else{
return "-";//Donot show Icon
}
});`