Ajax Json data using some Tables with options
Ajax Json data using some Tables with options
Hi all,
This is my first post here, so i will try to be the more explicit as possible !
In my project i'm using your great DataTables to display my values, these latter are retrieved from an PHP echo json_encode
. The PHP page is a script that return a json like this :
{
"sig1_re": [
{
"Ticket_RT": 716771,
"Cable_de_renvoi": 45,
"Longueur_de_ligne_(Selt)": 50,
"Res_LigneCoupee": "short",
"Ticket_fils": 152321,
"Numero_ND": "",
"Gamot_DateFermeture": "",
"Difference_de_date": "",
"Supprimer": "<a class='delete'><button>Delete</button></a>"
},
{
"Ticket_RT": 716760,
"Cable_de_renvoi": 45,
"Longueur_de_ligne_(Selt)": 67,
"Res_LigneCoupee": "open",
"Ticket_fils": "",
"Numero_ND": "",
"Gamot_DateFermeture": "",
"Difference_de_date": "",
"Supprimer": "<a class='delete'><button>Delete</button></a>"
}
],
"bad_nd": [
{
"Ticket_RT": 716620,
"Numero_ND": 236598741,
"Supprimer": "<a class='delete'><button>Delete</button></a>"
},
{
"Ticket_RT": 716577,
"Numero_ND": 565231583,
"Supprimer": "<a class='delete'><button>Delete</button></a>"
}
]
}
In my first attempt i code one JS file for each table in my HTLM and that works great but the inconvenient is that I repeat a lot of times the same code and call the JSON echo each time too. So i decided to regroup all my code in one JS file that will do the job !
And that's where the problems start lol
I managed to export almost all the tables options but I'm having a trouble to define some variables, one is to hideFromExport
because in my case i need only to copy the values from the first columns when i click on "COPY" button, the second problem is with oTable
which allows to delete the row. I would like to set these two things to be compatible with all my tables (in my below example i sue only two tables but in real i have more).
If someone with more skils can put me in the right way or give me the solution i will appreciate it. Thanks you in advance for the help.
my example : http://live.datatables.net/peceqofo/1/edit
Best regards.
Answers
Hi !
Here is the thread from stackoverflow : http://stackoverflow.com/questions/39148585/populate-datatables-ajax-json-object-from-php-using-multi-tables
Perhaps someone can help me here.
Regards.
Edit :
Well after a lot of research i found an solution for the commun button options, now that works good ! But i have got another problem, i want tot add a button + check (Delete function) to the Title of the last column and add a check (individual) at each row.
When i click on delete button i can't get the alert...
I hope someone more skilled can help me please.
Code : http://codepen.io/anon/pen/pbXrkB
Problem solved, just check Stackoverflow thread for the valid example.
Regards.
Looks like I got here a little too late to help. Glad you got it solved though! And welcome to the forums