Like mentioned in the other ticket, this can't be done with any built-in features of the plugin, and would have to be done manually with some custom code.
Changing the width of columns is only possible if you disable the "Scrollable" feature in the "Display" tab above the table, and enable "Limit table width". When you do that, a new option (Column Width) will appear in column settings, but this will be applied to desktops.
Making it work in the same way for mobiles and tablets, you'd need to include custom media queries.
I can only give you an example, but writing custom code is not included in the provided support for the plugin, so I can't help you with it in more detail.
You can add a custom CSS class to a column (for example "smallscreen"). Then, in Custom CSS section of the Customize tab above the table (or in Custom CSS in wpDataTables Settings), you can add something like this:
@media only screen and (max-width: 600px) {
.wpDataTablesWrapper table.wpDataTable th.smallscreen,
.wpDataTablesWrapper table.wpDataTable td.smallscreen {
width: 20px !important;
}
}
th applies to the header, and td applies to the rows.
So, this CSS will change the width of the column that has "smallscreen" custom CSS class, on screens lower than 600px.
Hello,
(How) Can I set a different % width for different columns in a wpDataTable depending on the screen size in which they are viewed?
Thank you!
Hi again Sebastian
Like mentioned in the other ticket, this can't be done with any built-in features of the plugin, and would have to be done manually with some custom code.
Changing the width of columns is only possible if you disable the "Scrollable" feature in the "Display" tab above the table, and enable "Limit table width". When you do that, a new option (Column Width) will appear in column settings, but this will be applied to desktops.
Making it work in the same way for mobiles and tablets, you'd need to include custom media queries.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
Thank you for clarifying.
(How) Can I use media queries to set different column width on a column-by-column basis depending on screen size?
Hi again Sebastian
I can only give you an example, but writing custom code is not included in the provided support for the plugin, so I can't help you with it in more detail.
You can add a custom CSS class to a column (for example "smallscreen"). Then, in Custom CSS section of the Customize tab above the table (or in Custom CSS in wpDataTables Settings), you can add something like this:
th applies to the header, and td applies to the rows.
So, this CSS will change the width of the column that has "smallscreen" custom CSS class, on screens lower than 600px.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
Understood. This is very useful and exactly what I need.
Thank you for your guidance as I'm not overly familiar with css.
You're welcome, Sebastian
Glad I could be of service.
If you have any further questions or issues, please feel free to open a new ticket, and we'll gladly help.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables