adding wrapper around table in tablepress
-
I want to add a wrapper around table in tablepress, Where can i modify the code for doing this.
-
Hi,
thanks for your question, and sorry for the trouble.
The best way for that should be to use a the
tablepress_render_outputfilter hook. With that, you can use code likeadd_filter( 'tablepress_table_output', 'tp_add_wrapper', 10, 3 ); function tp_add_wrapper( $output, $table, $render_options ) { $output = "<div class=\"tablepress-wrapper\">\n{$output}\n</div>"; return $output; }e.g. in your theme’s functions.php or a small new plugin file. That way you don’t have to modify the TablePress plugin files, as you would lose those changes after a plugin update.
Regards,
TobiasSorry for asking again,I want to add wrapper just around the table, so that i can border the table.
Hi,
ok, I might not be understanding what you mean then.
This will add a wrapping<div>element around the table.
Is that now what you want?Or do you only want a border around your table? Can you please post a link to the page with the table where this problem happens, so that I can take a direct look? Thanks!
Regards,
TobiasURL: http://cyberbel.com/
I had inserted the code in functions.php, but it was wrapping ‘dataTables_wrapper’ container not just the table. Instead I want to wrap around the table, so that i can apply border around the table wrapper.Presently the code looks like:
<div class=”tablepress-wrapper2″><div id=”tablepress-devTools_wrapper” class=”dataTables_wrapper” role=”grid”><div id=”tablepress-devTools_length” class=”dataTables_length”><label>Show <select size=”1″ name=”tablepress-devTools_length” aria-controls=”tablepress-devTools”><option value=”10″ selected=”selected”>10</option><option value=”25″>25</option><option value=”50″>50</option><option value=”100″>100</option></select> entries</label></div><div class=”dataTables_filter” id=”tablepress-devTools_filter”><label>Search: <input type=”text” aria-controls=”tablepress-devTools”></label></div><table id=”tablepress-devTools”
Instead I was expecting, tablepress-wrapper2 to wrap around table tag
I want to wrap the table so that I can apply border radius to the table.
Hi,
thanks for the detailed explanations! This won’t work like this, unfortunately. The
dataTables_wrappercontainer is added on the fly by the DataTables JavaScript library, via JavaScript, and because of that, it will always be the direct wrapper for the<table>element.You would have to tell DataTables to add another wrapper for you, but for a rounded border, you should actually not need a wrapper.
It should be enough to add some “Custom CSS” as described in this thread: http://ww.wp.xz.cn/support/topic/can-tablepress-do-this?replies=9By the way: Many links/ressources on your site are being loaded from
localhostinstead of the real domain, which means that they will only load for you. You should fix that!Regards,
TobiasThanks for the response. The link which you provided would work for me to apply border radius. Thanks for finding the ‘localhost’ link issue, I missed noticing them.
Hi,
no problem, you are very welcome! 🙂 Good to hear that this helped!
Best wishes,
TobiasP.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!
Thanks for the snippet, Tobias
As mentioned it only works with javascript enabled for the table
Hi,
can you clarify? The code from my first reply does not need the JS library to be enabled.
Regards,
Tobias
The topic ‘adding wrapper around table in tablepress’ is closed to new replies.