Laravel Backpack Update Datatable via ajax when select field change - laravel

i am new to laravel backpack. I have a view where i have to show some details of a category, i have a dropdown list of categories on top and datatable below it listing all the details i want to update this data table when any category is selected and I want it use ajax so that it wont load the page again. I was unable to get any clue in the documents. Can someone point me to the correct way to implement this. Thank you in advance!

In Laravel backpack v4 as far I know you can use the variable crud and by calling this crud.table.draw()
You can see the file in datatables_logic.blade.php.
JQuery(document).ready(function($){
crud.table = $("#crudTable").DataTable(crud.dataTableConfiguration);
...
)}

Related

Exporting all data from table using laravel backpack

I want to export all data from the products table which has more than 10k products in it. I'm using the backpack in this project and while clicking export csv only the current page will be exported. Any solution for this?
Thank you in advance :)
The export functionality is currently handled by the JS Datatable. So I'm not sure if an export with over 10k entries would work. This could be the reason why just the current page will get exported.
But I've found a little workaround. The following is stated in the Laravel Backpack docs (Link) about export:
Please note that when clicked, each button will export the currently visible table. You can use
the "visibility" button, and the "Items per page" dropdown to manipulate what is inside the export.
So try to change the amount of items in your table by using the Visibility option in the dropdown or the Items per page selection under the table to export more than just one page.
I hope this will work for now and someone else can find a solution to export everything.

Laravel 5 dynamic content from selected dropdown

Hello I'm new to laravel I was trying to find the solution but unsuccessful.
I manage to get the selected value using ajax but I cant show results in the same view that I selected from.
Let me explain what I want to achieve.
User select the value(id) from dropdown (populated from DB)
the value id need to be pass to controller get new array of a query result
return an array to the same view with show what was selected in dropdown
Any suggestion I will appreciate.
Thank you.
What I understood is , you want to populate one select box based on another select box value,
He are some best start tutorial for you,
http://www.9lessons.info/2010/08/dynamic-dependent-select-box-using.html
http://blog.chapagain.com.np/using-jquery-ajax-populate-selection-list/

How can I add a <CreateButton> (seeding the foreign key) to a ReferenceManyField in admin-on-rest

I have an edit form for a Post record, and I'm listing the Reviews associated with that Post in a ReferenceManyField/DataGrid (ie <ReferenceManyField target="post_id" reference="reviews">). Each Review has the foreign key post_id in the DB. This is all working fine, I have an edit and delete button for each Review row.
I need to add a 'Create Review' button for the Post form, such that the post_id field in the Create Review form is pre-populated with the current id of the Post. I'm not very expert in React/Redux.
As #Gildas has suggested above, you need a custom component for that.
1) A custom create button that routes to a create page for the review. For this you should look at how the React Router Link component documentation as well as how Admin On Rest would allocate a route for instance /:reviewId/create
2) Create a custom input component that will prefill the ID when loaded. This should be part of the location key in the props passed to your page. Ask additional questions as comments and I will try and answer them.
React and Redux are really simple things when you get the hang of them
This is not possible directly for now: you'll have to create a custom component for that: documentation.
Someone tried to address this issue and even supplied a pull-request. Hopefully we'll be able to merge it soon: https://github.com/marmelab/admin-on-rest/pull/744
Edit: this might help https://marmelab.com/blog/2018/07/09/react-admin-tutorials-form-for-related-records.html

How to load datatable on change of dropdown

I have a view where there is a dropdown and datatable.
At initial load, I am loading the values to be loaded in the datatable based on the first select of dropdown and on change of dropdown, I want to fetch data based on that condition and populate those data on the datatable.
Please anyone suggest a way to do this!
I am trying a way using get request but it is reloading the page and hence I am unable to make the data persist in the datatable.
I followed exactly this https://laracasts.com/discuss/channels/laravel/filtering-data-using-drop-down-onchange-event
Data is coming and populates to the datatable but just after a second, it reloads and comes to old data in datatable.
Please either correct my or suggest some new way to do it!
After debugging, I found that in one of the js file included, there were a code
$(document).ajaxStop(function() {
window.location.reload();
});
Since, this code was making it to reload on every ajax call completes, I faced this issue.

CakePHP display updated table of data using ajax

I'm having real trouble finding any documentation on this.
I have a page that displays a list of users, above this i can edit the users successfuly with ajax. After the update, i want the table below to be updated with the new information.
How do i go about doing this? I'm thinking i need some sort of view that displays the data in a table, and i want to get that view's contents and inject it into my page, but i can't seem to find out how?
Can anyone point me in the right direction please
Put users table in div id like "Users" and do something like following in edit ajax success function call
$("#users").load("same_page_url #users");

Resources