How Do I add items to pop-up modals and stylize ADD-EDIT-DELETE buttons
How Do I add items to pop-up modals and stylize ADD-EDIT-DELETE buttons
Im struggling with some what I hope are basic items when using datatables editor.
1) for the modal pop-ups that occur when editing or adding how do I modify these. For instance Id like to add a cancel button beside the create button when adding and also provide some informational text inside the modal pop-up to help users
2) the default New-Edit-Delete
buttons I want to stylize using bootstrap
ie. <button class="btn btn-complete btn-lg fs-17 bold ls-negone" data-toggle="modal" data-target="#addFAQ"><i class="fa fa-plus"></i> Add New FAQ</button>
Ive looked high and low and Im at a total loss as to where and how to do this. These simple items are proving to be a huge time vampire so hoping this is doable.
Thanks for any help
This question has accepted answers - jump to:
Answers
Hi,
Use the
buttons()
API. If you want to modify the TableTools "edit" button, you would use the$.fn.dataTable.TableTools.BUTTONS.editor_edit.formButtons
array to define your buttons (with the same array options thatbuttons()
takes.There is an example of how to use the
formButtons
option here.For fields use the
fields.fieldInfo
option. You can also use the API methodfield().message()
.Have you included the Bootstrap integration files?
Thanks,
Allan
Thanks Allan,
But the docs are proving fruitless for me. I've searched high and low through the website, the forums, Google you name it and for some reason cannot find a concrete and simple example of how to...
1) change the style of the Add-Edit-Delete buttons as used by the editor to have it take on bootstrap button style - should be easy but Ive exhausted every avenue here
example: Heres the button I would like to see for say adding a new item
<button class="btn btn-complete btn-lg fs-17 bold ls-negone" ><i class="fa fa-plus"></i> Add New Item</button>
I have bootstrap fully integrated into my framework so that's a non issue
Im assuming I could place the class portion into some sort of class setting somewhere but unable to find where
2) adding a simple cancel button in the modal pop-up that appears when adding, editing or deleting
Ive purchased the editor addon and cannot find the answers I need. My framework already has bootstrap included so the datatables is simply added into my framework and that part works fine.
The editor itself is working fine and I have it hooked up to my dbase so all good there and it has been a real time saver for sure. However the simplest of tasks in terms of styling the datatables has been a real nightmare. It's likely me but it's been a struggle.
:::::::::::
What I have now...
var editor; // use a global for the submit and return data rendering in the examples
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
} );
One last question in regards to editor and server side processing, is this using PDO prepared statements for adding and editing of data?
Thanks again for your help, product is great but Im not a jscript guru and just need a solid example to work from and should be good to go
Try:
I am assuming that you have included the DataTables / Bootstrap integration file.
Use:
Unfortunately you need to add the
formButtons
option to all three TableTools buttons, assuming you want the cancel button on all three form types.Yes :-).
Hope this helps!
Allan
Awesome, thanks Allan. I'll give these a try.
Question - Are you available to help fix a bunch of these small types of items we have? Paid work of course.
We have a framework in place but we have a number of small nagging items we just need to get done and out of the way as we're finding we are spending way to much time trying to get things in datatables done (sifting through forums etc) that I'm sure you could do rather easily.
Please let me know if interested and I can prepare a list of items for you and you can quote me a cost or I see you have support credits, whatever works best for you.
Thanks again
Hi,
At the moment I'm afraid I'm not available outside providing support for the software published on this site. Too many new features I'm working on :-)
Allan
Not a problem, thanks again
Allan,
Sorry still having 1 issue with trying to get a "Cancel" or "Close" button to show up when using the Editor for adding/editing pages in the modal popup.
You provided me with this...
But it errors out...
:::::::::::::::
I have the following in place...
Thanks again
Sorry - there was a missing
}
in my code - this should do it:I've just tried it to make sure it works this time, and it does :-).
To show a Cancel button on all three forms (create, edit, remove) you need to provide the
formButtons
option that you want for each of the three buttons.Yes, the
formButtons
array is passed directly to thebuttons()
method so you can use any of the options described there. Specifically thebutton-options
type that is passed intobuttons()
provides aclassName
option, so you might use:If you would like a custom class name for the Submit button you would need to provide the submit button information as an object as well (can call
submit()
in thefn
function).Allan
Works like a charm
Thanks!
Sorry Allan, one more small item.
I also have inline edit and delete links for each row. Now when the modal is fired from those links the modal pop-up I also need to have a cancel button and to be able to style them but once again stumped. Can you provide an example using my code below
Here's an example of what I have right now which just has the default modal button so I need not only the update button bit a cancel button and to be able to style the cancel and update buttons as well...
Thanks again and sorry for all the small items.
The second parameter of
edit()
accepts aform-options
object. That includes abuttons
option, which (like above) is simply passed tobuttons()
. So at the moment in your code you have a singleUpdate
button. If you want a cancel button there as well, you would just add the buttons array we discussed in its place.Allan
Thanks Allan, got it working now.