Print to secondary table
Print to secondary table
jalape
Posts: 117Questions: 2Answers: 1
in TableTools
Good afternoon everyone,
Based on the example: https://datatables.net/blog/2019-01-11
In the secondary table I have created a print button with the parameter:
messageTop: 'rowData.tb_nota.id',
What I intend is that it shows me when printing the content of the secondary table, the id of the main table.
Thank you
This discussion has been closed.
Replies
You will want to use
messageTop
as a function as shown in this example. In the function you will use something like this should work`:Look at the
table().node()
docs for more details.Kevin
Thanks Kevin for answering,
Print me:
Parent table id: nota_tbl
If the table is correctly the name of the main and:
Parent table id: undefined
If the name is wrong, but it doesn't show me the id
Not sure what you mean. Please provide a link to your page or a test case showing the issue so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
http://javierlasen.es/easd2/login/admin_nota.php
By clicking on the Sec field, the secondary table opens.
Use the print button of the secondary table.
I'm seeing this in the Print file:
Are you expecting something different?
The code I gave you uses a hard coded table ID to get the table ID. Its redundant. You have this:
var siteTable = $('#nota_tbl').DataTable( {...} );
. Make sure the variablesiteTable
is in the global scope then you can make the function more generic like this:Kevin
I have globally declared siteTable and used the function, but the print message is still: Parent table id: nota_tbl
I have updated the changes in:
http://javierlasen.es/easd2/login/admin_nota.php
That code is getting the HTML ID of the parent table. If thats not what you want then provide specifically what you do want.
Kevin
My intention is to be able to retrieve data from main table as curso and grupo when printing with secondary table button.
Example:
2020-21
M-B
Secondary table
Your original post said this:
That is now fixed. Are you saying you have changed your mind?
I have not been able to see the id of the main table.
I haven't changed my mind, if I can read the id number from the main table, I will be able to see any field in the table, which is my intention.
http://javierlasen.es/easd2/login/admin_nota.php
Your link shows the id of the parent table in the printing of the child table. Why can't you see it?
But it is not showing the Id of the main table record. In all registers it shows the same.
Parent table id: nota_tbl
Store the ID of the clicked row in a global variable and use the same function technique to return that global variable.
Kevin
I'm afraid I don't know how to store the id of the main table record in a global variable. I've tried matching tb_nota.id to the name of a variable, but it doesn't work.
I have tried using data concatenating tb_nota.id, but neither.
This is your click event:
You have this config for your parent Datatable:
I think you want this column
{ data: "tb_nota.id" },
. You can do something like this with therow().data()
API:Make sure to declare a global variable, ie
var tb_nota_id;
. Then return that variable in the messageTop function.Kevin
Thank you very much Kevin for your time, now it has worked perfectly.
Investigating a little more, I have been able to see that it can be put in any position and use as many messages as you need: messageTop, messageBottom.
To be able to format the text and adjust the position a bit, I suppose it is using customize.
I love Datatable Editor.