Hide Search Box but show Create/Edit/Remove buttons (Editor)
Hide Search Box but show Create/Edit/Remove buttons (Editor)
welleozean
Posts: 9Questions: 2Answers: 0
Hello,
I starting to use the Editor version. In the past (simple Datatable) I used to have
dom: 'Z<"top"i>rt<"bottom"lp>'
to hide the Search Box (I have a customized one). Now, if I add this line, the Search Box disappears, but so do also the 3 buttons Create/Edit/Remove. I have not found any info about this.
Thank you.
This discussion has been closed.
Answers
The buttons are represented in the dom options by the letter "B", as explained in the docs.
https://datatables.net/reference/option/dom
Thank you. Probably I am misunderstanding something. I use Bootstrap 4 and the following:
Adding B to the DOM does not produce any effect (besides that the button Print is displayed)
You can use either the
B
in thedom
option or direct insertion like you have to place the buttons. This is described in this doc.If you are seeing the
print
button when using theB
dom option then that means you are loading the buttons JS/CSS files. The code above looks like it should work. You didn't post youeditor
config. Are you assigning your editor to the variableeditor
, ie,editor = new $.fn.dataTable.Editor( {
?Do you see errors in your browser's console?
You are missing something but the above doesn't show what that is. Can you post a link to a test case showing the issue?
Kevin
I have created the files with the Creator and have no changed them at all (besides for the config.php to communicate with the database). So it comes directly from the Creator. Buttons are displayed correctly. until I add the DOM line
dom: 'BZ<"top"i>rt<"bottom"lp>',
the Editor buttons disappear and the Print appears.
I can upload a copy, but again is the very same I just downloaded with no editings.
Here is the javascript as from the Creator for the Editor
var editor = new $.fn.dataTable.Editor( {
Here is the live example:
http://windsurfinglanzarote.com/editor/mobile
The problem is you don't have the class
col-md-6
in the HTML. If you go to the BS4 Editor example and inspect the area where the buttons are you will see this:You don't have that structure. I think its because you have
dom: "B"
. If you use thedom
option with BS4 you should use the styling as shown in the docs. I don't think it is intended to use theB
in thedom
option and use the direct insertion method of:Use one or the other.
The default
dom
setting when using BS4 looks to be what is shown in the above linked styling section. Since you are usingdom: 'Z<"top"i>rt<"bottom"lp>',
you have removed those classes so they aren't in the page when you use the selector of.col-md-6:eq(0)
.Long story short you either need to find a different selector to use (you may need to manually place a
div
where you want the buttons) or change yourdom
to include the documented styling.Kevin
Hi Kevin,
thank you for your valuable feedback. However, I do not get it. Even the example you showed me (the main HTML page), if opened for inspection does not have the class col-md-6. If I delete the DOM specification from my example, the buttons appear.
So I surely not understanding some basic principle, but I am struggling a lot. Note, this is the only part I am struggling with. Otherwise I find the all Datatable very intuitive.
Provided I want to add a custom
<
div> and append there the buttons, how sould I proceed? The following does not work (my Javascript knowledge is miserable):
I added in the main HTML:
<div class="editingbuttons"></div>
The Javascript is modified as:
This of course does not work. How should I proceed?
Of course, I can obtain the same result fiddling with the CSS. The following for example works (using no DOM):
But I pretty sure this is not the right way to go.
Thank you
Datatables adds the
div
with those classes when it initializes. Thedom
option is used to add them based on the styling (BS4 in this case) used. If thedom
option is not provided then Datatables will use the default shown in the docs which adds thediv
s with the col-md-6 class. You are over-riding this default withdom: 'Z<"top"i>rt<"bottom"lp>',
.You probably need to remove the
table.table().container()
portion of the selector, resulting in this code:Kevin