JohnTendik / jtrt-tables

A Wordpress plugin to help users create responsive tables without having to read or write code.
GNU General Public License v2.0
22 stars 6 forks source link

Pagination, Filter & Sorting #97

Closed heroeexceso closed 4 years ago

heroeexceso commented 4 years ago

Good morning. I am starting to use WordPress and getting to know this plugin. The problem I have is generated when I load the table dynamically. I have configured the table with the plugin, and I load the information using the $(“# jtrt_table_18489 tbody”).Html(list) statement; . Although the table is fully loaded, it does not restrict the number of rows configured for paging, the search does not work, etc … Would you have a complete example? The plugin version is the latest. From already thank you very much!

heroeexceso commented 4 years ago

I was testing with this code:

var ft = FooTable.init('#tabla1', { 'expandFirst': false, 'empty': "La consulta no devuelve resultados" }); ... var itemJson = { 'options': { 'expanded': false,
}, 'value': { 'Col1': { 'options': {'classes': 'border-right border-left'}, 'value': "valor1" }, 'Col2': { 'options': {'classes': 'border-right border-left'}, 'value': "valor2" },... } ... arrayJson.push(itemJson); .... ft.loadRows(arrayJson);

But although I see that the table has lines, they are empty ... I do not see how I can relate the fields of the grid created in the plugin with the code to load it ...

JohnTendik commented 4 years ago

How come you're not using the shortcode and initializing the plugin manually? If you use the shortcode it should already initialize the table with all the scripts.

heroeexceso commented 4 years ago

Hey, thanks for the answer... The shortcode is [jtrt_tables id="18489"]... (replace ''#tabla1'' with '#jtrt_table_18489') The question that you still cannot solve is how do I load the table dynamically? I get the information through the execution of an API and not through a csv. Is it correct to use the indicated sentence? Or is there another way? Thank you very much for the help...

JohnTendik commented 4 years ago

Oh are you asking if there is an api to get the table data back? Because if so, no, that is not an option. The idea for this plugin was to use it without any kmowledge of coding or html so there was never a need to inciude an api. Unfortunately that is also not something I plan on adding, especially since im only providing quality of life support for this plugin.

If you feel confident enough, feel free to submit a PR and I will merge it.

Thanks JT

JohnTendik commented 4 years ago

Actually if you really need to do this, You could get the content of the custom post type which has all the table data and settings in a json array.

Simply query the custom post type jtrttable with the id and then get the content.

Pseudo code below $tabledata = get_post(id)->get_content()

I dont know if the above will work, im just providing it as an example. Look up how to query custom post types and get data frok that object.

PS this must be done in php, you can create an ajax function that you call from the frontend or create an endpoint for the resp api. Up to you.

heroeexceso commented 4 years ago

I really appreciate the help. The API I mentioned earlier is the one that allows me to get information from a database, and that information will be used to fill the grid... Is it possible to do that without using a csv file?