Ajax table view doensn't work with model_function columns
See original GitHub issuemodel_function, model_function_attribute columns doesn’t use actual db columns, so this causes an issue in search() function in trait AjaxTable:
$columns = collect($this->crud->columns)
->reject(function ($column, $key) {
// the select_multiple columns are not searchable
return isset($column['type']) && $column['type'] == 'select_multiple';
})
->pluck('name')
// add the primary key, otherwise the buttons won't work
->merge($this->crud->model->getKeyName())
->toArray();
// structure the response in a DataTable-friendly way
$dataTable = new \LiveControl\EloquentDataTable\DataTable($this->crud->query, $columns);
This code tries to select non-existent fields from entity table. I think that the right thing would be to replace “reject” method with “filter” and list the types of fields out there that use the real database fields (so user defined types also will work) like that:
$columns = collect($this->crud->columns)
->filter(function ($column, $key) {
return isset($column['type']) && in_array($column['type'], [
'array',
'array_count',
'boolean',
'check',
'multidimensional_array',
'radio',
'text',
'select',
'video'
]);
})
->pluck('name')
// add the primary key, otherwise the buttons won't work
->merge($this->crud->model->getKeyName())
->toArray();
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Table functions doesn't work when using ajax - Stack Overflow
And I created a page and the fetch function works but when it's in the table, the table functions doesn't work. At the...
Read more >Unable to get columnDefs.render to work on columns coming ...
In order to dynamically create the DataTables table I have piggybacked the DataTable init on the return from the "get columns" AJAX request....
Read more >Beautiful Interactive Tables for your Flask Templates
In this article I'm going to show you how to integrate the dataTables.js library in your templates, which will allow you to create...
Read more >django-ajax-datatable - PyPI
django-ajax-datatable is a Django app (previously named morlandi/django-datatables-view) which provides advanced integration for a Django project with the ...
Read more >DataTables.js for Django. Python Classes to ... - Medium
DataTables.js for Django. Python Classes to Implement AJAX Data Table in Django. Hi. In this text, I am not going to write everything...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@adbmdp yeah, I think I fixed it, but i’m still testing. I will let you know when we’re done. You can checkout my solution here: https://github.com/indra1/CRUD (check the AjaxTrait.php file)
@MDEvo he is a she. And yes, I removed a library and I added some functions @tabacitu it works, but I would like to test it for two more days. Sorry for the delay, I was caught up in something else. I also want to try to change the search function to allow it to sort by relations as well. Edit: found a bug, and fixed it. I have the package loaded in a project now and besides that bug all seams to be well.
Do you guys have any proposals for that?
Edit: some people were saying it’s kind of slow so i’d like to look into that as well. Please let me know your thoughts