A few weeks ago, I was approached with a question on whether it is possible to make the textfields on the “Edit” screen of a table wider, to allow for an easier editing of long text. As this might also interest other people, I decided to publish the solution as a WP-Table Reloaded Extension.
My thanks for making this possible go out to the folks at ningboHOTELreview.com. Thanks!
To get started with WP-Table Reloaded Extensions, you should read the introduction and follow the included instructions. You will also find links to the other presented Extensions there.
Now lets come to the actual code of the Extension:
/**
* Change default textfield width on the "Edit" screen
*/
if ( is_admin() ) {
function wp_table_reloaded_textarea_width_css() {
?>
<style type="text/css" media="screen">
/* Change all columns */
#table_contents textarea {
min-width: 400px;
}
/* Change only textareas in column A */
#table_contents .edit_col_1 textarea {
min-width: 780px;
}
</style>
<?php
}
add_action( "admin_print_styles-{$WP_Table_Reloaded_Admin->hook}", 'wp_table_reloaded_textarea_width_css' );
} |
Important: The code from above is not yet ready to use! (Well, it would work, but is not really useful.) Before it will be useful to you, you need to adjust the included CSS code, so that it changes the width to what you want. You can see two sections of CSS code, marked by a comment line above them. The first one is responsible for setting the textfield width on all columns of the “Edit” screen. The second example only changes those of the first column. You can copy that section as often as needed (don’t forget to change the “.col_1″ to whatever you need). For both sections you can then set the width to any pixel value you like, by simply changing the number after the “min-width:” attribute.
Then, the code just needs to be copied into the file “wp-table-reloaded-extensions.php”, created according to these instructions (after the Plugin Header comment, but before the closing PHP bracket ?>). Then, just activate the new plugin “WP-Table Reloaded Extensions”, if you haven’t. That’s it! :-)
If you like this series of Extensions, I’m happy about any feedback, and especially about further suggestions!
Previous posts in this series that might interest you:
- Announcement and Foundation on Extensions
- Extension 1: Automatic URL to Links conversion
- Extension 2: Custom Name in the Admin Menu
- Extension 3: Changing the Table Shortcode
- Extension 4: Changing DataTables strings
- Extension 5: How to use PHP in table cells
- Extension 6: Showing only rows that match a filter


This is an amazing plugin, Tobias, many thanks.
Any idea on how to change the height of the textfields, I tried adding a CSS line to the code “min-height”, but it’s not working. Thanks.
Hi Sami,
that’s weird, it works fine for me, if I do that. What browser are you using?
And is original code to increase the width working?
Best wishes,
Tobias
Hi Tobias,
actually no, the width is not working as well!
Also, I have 2 other questions:
1- is it possible to assign a specific color to a specific cell in the table without affecting the other cell of the same row or column?
2- is it possible to add a PDF in the download option you offer?
Keep on the great job man, you saved me a lot of work!
Hi sami,
that’s weird. I don’t really know why the width is also not working… Are you using the latest version of your webbrowser?
Styling a single cell is possible with CSS, please see the FAQ question “How can I highlight certain cells or their content?”.
For the PDF option: No, sorry, that is not possible, because creation of a PDF file is non-trivial.
Best wishes,
Tobias
Doesn’t work for me ;( Isn’t that important though.
Hi Lembit,
that’s weird. Have you activated the Extension plugin?
Best wishes,
Tobias
Yes, of course. I tweak the frontend view/functionality of tables a lot via extending.
Doesn’t work for me as well … :(
I’m using Firefox Portable 3.6.x
Hi Tobias,
I’ve recently found your website and this useful plugin but I have a problem with this, I don’t know how can I run your plugin with a Magazine theme in WordPress, because your plugin works perfectly, but my theme uses jQuery and I want a way to modify my theme or your plugin to make both work correctly.
I hope you help me please :(
Hi,
can you describe a little bit more in detail, what you are having problems with?
Regards,
Tobias
Hi Tobias,
Thanks for the plugin – it’s great, however is there a way for me to embed some PHP cpde into a cell and have it executed at run time? When I try it seems to just show the straight output?
Regards
Hi,
you can do that with a WP-Table Reloaded Extension, see http://tobias.baethge.com/2010/02/extension-5-how-to-use-php-in-table-cells/.
Tobias
Thank you for the plugin… exactly what I was looking for!
Hi,
I’m just getting into your plugin and its looking really good. Question for you: When I import a file from Excel instead of getting the table, I just get garbage. I know I’m missing something pretty here, but what?
P.S.: It works great, when I cut and paste the same Excel table into the blank form (manual method).
Thanks all.
Hi Chris,
this very likely happens because the Excel file is in some other “character encoding”, which messes up the import library. When you use the manual method, that character encoding is changed/neglected, and therefore the import works.
Unfortunately I don’t have a solution to that, so I can only recommend to keep using the manual method for importing files.
Best wishes,
Tobias
That worked a treat. Manual method does the job just fine. Thank you.
We are working on a very large site and would like to use the plugin extensively. Essentially one table per registered website user. Each registered user can then use links (in their personal BuddyPress profile) to get to their personal specific table and update the content in their personal table. Only problem is, all registered users with editing rights can then update everyone else’s table because there seems to be no role delineation between a user editing a table assigned to them and other users’ tables. Any ideas on that one? If I put it into perspective we envisage maybe 500 to 1000 live user tables, each assigned to a specific user with that specific user having table editing permissions – but what we need is that permission restricted to just the user’s own table not everyone else’s table.
And again, thanks Tobias, for a wow plugin. We can see this setting the standard!
Hi Chris,
thanks for the follow-up.
You are right, a user with editing rights can edit any table.
Unfortunately, this can not be changed. So, I’m very sorry, but it sounds as if the plugin is not the right thing to achieve what you need. You are probably better off with a custom solution.
(One thing that might work: If every user of your site had his own WordPress (as a member blog of a WordPress Multisite Network), the plugin could be installed in each of those blogs and everyone would only be able to edit table in his blog.
Other than that, I don’t see a possibility to achieve this in a single installation.
Best wishes,
Tobias
I think we have found a workaround and it’s possibly one you might consider as an update. The trick -we think- is to:
1. embed the users specific table in a page which is password protected. Only the user and (in this application) his boss and mentor have the password to that page.
2. Using something like S2Member move page permssions for list table, add table etc. (i.e. your top level menu) to admin or some permission level out of the reach of each specific table user who wants to edit just their own table (possibly in conjunction with thier boss or mentor).
3. So now the user gets a private table which can be used to track just about anything about that user (privately) and the user can edit the table in conjunction with anyone else who has access to users private page (here it is his performance and progress).
4. However user cannot get to the list or the add table etc pages because these pages are protected.
We think this might work, but it would be nice to avoid needing to use S2 just for protecting the list, add etc. pages by (optionally) restricting access to your top level menu items to a specific role. Table Editor maybe?
Now what you have with your table plugin is the core of personalised tables that can be maintained by the person or anyone with access to that persons private page. There are a wealth of applications here. Including ultimately adding personalised visual outputs like graphs maybe?
What do you think, Tobias?
Regards,
Chris
Hi Chris,
thanks for the feedback and information on your current solution.
I understand that you are in need of a more fine-grained control of user actions and rights within the plugin. However, I feel that this is outside the scope of the plugin. See, the goal of the plugin is to offer an easy way to create tables, without the need to manually mess with the HTML code behind it. It takes data, allows easy editing and displays it. However, it is not intended to be a spreadsheet application or graphing tool.
Sure, the features could be extended even further, but there will always be limitations, so it really is hard to fit everyone’s needs. So, while certainly some users (like you) would benefit from such a feature, I’m very sure that most others don’t need it and might only be confused from it. I have experienced this before, and had to see that every new feature, every setting and every option make the plugin harder to use for the people at which it is actually targeted.
Additionally, the implementation would certainly not be easy. There are a few things in the current structure of the plugin that would make per-table user rights very hard to control, and due to that, I don’t want to take that route at the moment. I hope you can understand that.
Best wishes,
Tobias
Hi,
Great plugin. I’m debating whether to use it for a rather large table (700 rows or so). The alternative is to develop an SQL database for this project (which I’m not too skilled at). Are there any practical limits/considerations to how large a table can be for this plugin?
Thanks
Hi Tim,
while there is no theoretical limit on the number of rows, I had to learn that there is one in practice: For each table cell, a text input field is shown on the table’s “Edit” screen. The more rows you have, the more text fields are necessary. Now, as it has happened, many such text fields will slow down a web browser significantly, making it hard to work on a table’s data.
Therefore, if you have the chance to use a SQL solution, I would recommend that for large tables. You can then still include all of the frontend features that the plugin offers, simply by manually using the JavaScript libraries.
Best wishes,
Tobias
Hi again Tobias,
determined not to use this plugin if we can! However to make the last workaround suggested be successful, we need to have the S2Member plugin prevent people without (say) S2member Level 1 or above membership getting to your Table List, Add New table Page. Don’t suppose you (or anyone else here) has figured out a way of that happening have you?
Chris
Hi Chris,
no, unfortunately I don’t know how to use S2Member together with my plugin. I have never used or worked with that plugin, so I don’t know the details on how it works. Sorry.
Best wishes,
Tobias
No problem and thank you, Tobias. The work you have done is fantastic. I do understand your reluctance to avoid creeping into areas beyond your original objective. Thanks for your help. Regards, Chris
Hello, first this is a wonderful plugin and thanks for it, my question is, on your baseball site when you click a players name, a drop down appears with all that players stats, how did you implement that, is there a step by step documentation to show how it is done? Thanks.
Hi Lou,
thanks for your comment. Unfortunately there is no such documentation on this feature available. It is a custom development I made for that side. It uses AJAX to grab the additional content and then adds it to the table. I can not provide any assistance for this feature, but I can only encourage you to take a look at the source code.
Best wishes,
Tobias
I checked at the right time, thank you for the reply, I will take a look at the source code, nice job on that site btw.