How to invoke Export, Print button on click functionality for bootstrap buttons
How to invoke Export, Print button on click functionality for bootstrap buttons
sanjeevmambat
Posts: 8Questions: 2Answers: 0
Hello,
I just want to know to invoke on click functionality of datatables button to my bootstrap buttons , without initializing datatables buttons.?
on click of bootstrap button Export or print of Datatables should work.
I am defining like this
datatableID.buttons('.buttons-print').trigger();
But for this to work there should be datatables buttons initialised which i dont want.
Can anyone help my out regarding this. ?
Thanks
This question has accepted answers - jump to:
This discussion has been closed.
Answers
If you want the functionality of the Buttons library, you would need to actually use that library. Its actions are not available via an external API.
Can I ask why you want to use your own bootstrap buttons rather than the bootstrap buttons that Buttons renders?
Allan
Hello Allan,
Thanks for the quick reply. I have my own custom toolbar defined where i have different functionalities. I have changed the look and feel of the buttons as required with icons and all.
The thing is i dont want one more layer of datatables buttons, so i would like to define the functionality of datatable buttons for my own buttons..
What you can do is use the DataTables buttons but just insert them somewhere else into the document (which you can do using the
buttons().container()
method to get their container node, and then use jQuery to inject it anywhere into the document). That way you could put the Buttons defined buttons into wherever your other buttons are.Allan
Hello Allan,
Thanks.. It worked.
Dear Team,
we are using the following example, there we have only one check box column.
https://editor.datatables.net/examples/api/checkbox.html
But we want check box for the multiple columns.
In this below method how to identify the multiple columns(like Active,Status,Expat) and assign the checked flag.
rowCallback: function ( row, data ) {
// Set the checked state of the checkbox in the table
$('input.editor-active', row).prop( 'checked', data.active == 1 );
}
Please furnish solution ASAP
Regards,
Rsanjeev
Hi Rsanjeev,
The key here is to have a different class for each checkbox. In the example the checkboxes use the class
editor-active
. You could useeditor-status
andeditor-expat
for checkboxes in other columns. You'd need to add suitable event listeners for those new classes as well.Regards,
Allan
Hi Allan,
Thanks for the reply, I have implemented the same way its working.
But I am facing the problem for the following scenarios.
In my case I am using Y or N flag instead of using 1 or 0 values.
Please go through the below code
Please give your advice
The
checkbox
field type has anunselectedValue
option that allows you to define the value that should be submitted to the server if the checkbox is not checked. Simply setting that property to beN
should resolve the issue you are seeing.Allan
Dear Allan,
we are new to data tables, Kindly provide one example code related to our questions.
I have attached the image please check that once.
We have created one data table, that table contains the 4 columns u can check in the image. we will submit all the rows at a time one click of Save button.
Pls go through the below mentioned problems,
If editor is not required how to update the status flag based on the check/uncheck ?
Not able to update the status flag to N whenever user unchecked the status flag. Its getting updated to empty string to row to a data table.
How to check / un check the checkbox through programatically for the other check boxes in a row?
I want to reload the data into Data table through ajax call , how to do this?
Please respond with example code ASAP.
Its urgent.
Please go through the below full code.
Regads,
Sanjeev.
Hi,
All I think you need to do is add the
unselectedValue
property that I mentioned above. i.e.:Regarding your specific questions:
I don't see any reason why you can't use Editor to do what you are looking to do.
Editor is not required, but I think it will be easiest if you do use it.
See my comment about above using
unselectedValue
.The code you have in
rowCallback
should be doing that already. If is isn't can you give me a link to the page in question so I can take a look at it and debug it please.The
ajax.reload()
method can be used to reload the table's data.Allan