Giter VIP home page Giter VIP logo

Comments (5)

TobiasBg avatar TobiasBg commented on June 10, 2024

Hi,

thanks for your suggestion. For this, there are two methods:

First, you could set a new CSS styling for the rows manually, via https://tablepress.org/faq/change-background-color-of-a-row/

Alternatively, you could instruct TablePress to add such a special CSS class to rows based on its content (or keywords in a row), using the idea from https://wordpress.org/support/topic/highlight-a-row-based-on-value?replies=16

Adding a direct option for typing row CSS classes into TablePress is not something that I consider at the moment, as it would only make the user interface more confusing for the majority of plugin users.

Best wishes,
Tobias

from tablepress.

buffaloseven avatar buffaloseven commented on June 10, 2024

Thanks for the quick response. I've played around with all options, and a bit of feedback:

  1. Global CSS styling isn't great simply because that means I have to maintain an ever-growing list of row highlights.
  2. Your row highlighting extension is very close to what would be idea, but again, it results in the need to maintain an ever-growing list of row highlights via custom classes.

I've settled on utilizing DataTables for row highlighting by adding the following code:

"createdRow": function(row, data, index) { if (data[column_index] === "[string_to_match]") { $(row).addClass('[class_to_add]'); } }

It's a little complicated for some of the contributors to my blog, but it does in a pinch. However, it will not work if I'm not utilizing DataTables or if a user [unlikely] has Javascript disabled.

What would be ideal would be if your row highlighting extension had a flag to apply a class name instead of generating the row-highlight-$highlight-term. Looking through the PHP, it wouldn't be to tricky to add, so I could possibly do it and file a pull request. Adding the class on the back-end would be preferable because then I can be assured it will show up on all users' computers.

Thanks for the quick feedback!

from tablepress.

TobiasBg avatar TobiasBg commented on June 10, 2024

Hi,

yes, directly applying CSS to the individual rows would result in large chunk of CSS code.
The Extension could reduce that amount (and especially the need to adjust the CSS when a row position has changed). At the moment, the Extension does indeed add a unique (per-highlight-term) CSS class, but this should only be a problem if you use many different highlight terms. That's however the same in your JS code example, from what I can see.

One idea would be to use CSS attribute selectors, like

.tablepress tr[class*="row-highlight-"] td {
  background-color: #ff0000 !important;
}

This would match all highlighted rows, regardless of the highlight term.

Of course, you could adjust the Extension to add a fixed CSS class as well, which would shorten the CSS. (I don't have the Extension in a public repo here, but I'd be happy to see the results.)

Adding an option to directly add a row class on the table's "Edit" screen is not something that I'm considering, simply because it will make the user interface more complex, and the benefit is marginal compared to the available workarounds.

Regards,
Tobias

from tablepress.

buffaloseven avatar buffaloseven commented on June 10, 2024

I hadn't thought about using a generalized class selector; that's a good idea.

I may work on adding a generalized custom class specifier to your PHP code. I'm utilizing bootstrap for my site and ideally would just apply Bootstrap's info, success, warning, and danger classes to table rows.

In the meantime, I'll just apply your generalized CSS selector until I get the custom class stuff working!

Your plugin is great though, and definitely my preferred way of letting my contributors integrate DataTables into their posts.

from tablepress.

TobiasBg avatar TobiasBg commented on June 10, 2024

Hi,

that's sounds great! I see what you are trying to achieve, and this should work fine.

Best wishes,
Tobias

from tablepress.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.