Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Keith

editing css for cells

Can you help get me further along with this task?

I sort of asked it before, but I have a clearer understanding of things now.

OK…

When my columns load, I want to apply CSS to the cells (background and text colors) depending on the values in the fields.

Essentialy, I determine whether a Project is “late/complete”, “late/incomplete”, “on-time/complete” based on comparing two fields: Planned Date, and Actual Date (and sometimes factoring in current date).

First question…

Would a good way to do this be:

1) Generate JSON with the selector and classes
2) Use AJAX on page load to apply the styles? to every cell, even if the records aren’t loaded?

Secondly…

When a specific field (Actual Date) is edited from Admin Columns, I might have to re-apply the CSS styling…

What’s a good way?

I thought that I could possibly:

1) Pass the field name to an AJAX file (but how?)
2) Request the styles based on the field name (and doing the calculations based on other fields to determine the colors)
3) Overriding the cell’s styles

I know this is a big question… I just need some guidance in how I could do this in relation to Admin Columns. I will sort out the code and the WP-specific end of things myself.

Thanks in advance!

Back to watching the jQuery/AJAX course on Treehouse :)

6 years, 6 months ago
Stefan van den Dungen Gronovius
Developer

Hi Keith,

About your first question. Is there a reason why you want to tackle this issue with Ajax? Since you already know which style you want to apply to which value, you don’t really need to get that information from the server right?

My first idea was to wrap the content inside a HTML container with the correct css class applied by using the value filter.

ac/column/value


This even works for the values that are returned after editing the value by using inline edit.

About your second question. When you edit the value of a column with Admin Columns, we do an Ajax request. The response of this request contains the new value, but it also contains the whole rendered row for the specific post. I explained this on this topic: https://www.admincolumns.com/forums/topic/conditionally-refresh-a-row-upon-update/

If you used the filter I mentioned for your first question, all styling should already be in place in the row content and you can just replace the current row with the new one from the Ajax response.

Do you think that might work? It sounds easier than doing all kinds of Ajax calls yourself.

6 years, 6 months ago

You must be logged in to reply to this topic.