Show datagrid without any framework

Hi @johnny , i need your help, using gc without any framework.
The backend works great, it is more about the frontend.
Lets say i have some content, three buttons and a div especially for the datagrid. With each button i want to “select” a different table, and display the datagrid in the “gc-div”, without reloading the rest of the page. I can do it by reloading everything, and i guess using a controller and a view in codeigniter would do also, but i have the restriction to not use any framework.
What code should i use in the onclick of the buttons, to be able to send the datagrid to the div without having to reload the rest…
Thanks in advance for any hint
Marc

Hello @MarcVdB ,

Yes you can do that. It needs first steps for this.

  1. Use the setUniqueId function to have a uniqueId for each of your datagrids setUniqueId - Grocery CRUD - A PHP CRUD Generator Library let’s say:
$crud->setUniqueId("customers_1234");
  1. Now you can specify you can refresh your datagrid by having the below JavaScript call:
groceryCrudLoader(document.querySelectorAll('.grocery-crud[data-unique-id="customers_1234"]')[0]);

Considering that customers_1234 is the uniqueId you have provided in the first step.

The above code will refresh only the datagrid you have specified. I hope this helped.

Regards
Johnny

Hi Johnny,
i think setUniqueId was the clue i was missing. Will have time this weekend to look at it.

In anyway, thanks for your quick response!
Regards,
Marc

1 Like