Hello AG family, I need some assistance!
I am tying to change the color of a row in my table based on a column status.
The table is named: Move_Log
and the column that needs to control the colors is called: Status
The three status are:
MC
WU
Scheduled
I would like the rows in the table to be highlighted the following color based on how the Status is set.
MC=success
WU=danger
Scheduled=primary
I need the following, a quick code solution, example, and directions where to put the code.
Thank you in advance.
Table View Highlight
Re: Table View Highlight
hi,
Have a play with this
insert it in the footer-extras file
Have a play with this
Code: Select all
<script>
$j(function(){
$j('.TABLE-NAME-FIELD').each(function(){
var QRZ = $j(this).text();
if(FIELD == 'NAME TO BE COLORED'){
$j(this).parents('tr').addClass('info');
}
})
})
</script>
insert it in the footer-extras file
23.17
Re: Table View Highlight
Cool, I will work on that right now and see what happens.
Re: Table View Highlight
<script>
$j(function(){
$j('.Move_Log-Status').each(function(){
var Status = $j(this).text();
if(FIELD == 'MC'){
$j(this).parents('tr').addClass('danger');
}
})
})
</script>
any help please?
$j(function(){
$j('.Move_Log-Status').each(function(){
var Status = $j(this).text();
if(FIELD == 'MC'){
$j(this).parents('tr').addClass('danger');
}
})
})
</script>
any help please?
Re: Table View Highlight
There should be an error message in console, telling FIELD is undefined. Try Status instead of FIELD.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Table View Highlight
You are amazing!!! That did it thank you!
Re: Table View Highlight
Additional ask....
If I want make field highlighted say yellow fill with red text, would you be able to assist me on that as well ???
If I want make field highlighted say yellow fill with red text, would you be able to assist me on that as well ???
Re: Table View Highlight
Hi utony,
as you are adding the CSS class danger to the field, just define a CSS to your liking (yellow with red text).
This should work.
You may want to add !important to color definitions in the class as well.
Olaf
as you are adding the CSS class danger to the field, just define a CSS to your liking (yellow with red text).
This should work.
You may want to add !important to color definitions in the class as well.
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: Table View Highlight
Olaf, anyway you can provide a code example and tell me where to put it? I am a bit of a beginner and not as advanced as you. any thanks in advance for your time.
Re: Table View Highlight
There are certain default classes with predefined color settings in your selected theme:
It is recommended to use those because users are used to those colors and should immediately understand the meaning.
---
Anyway, if you need different custom color combinations, you can define your own CSS classes with color styles:
In header-extras.php:
You can create multiple here with different class names.
Inside your javascript file:
- success
- info
- warning
- danger
Code: Select all
if(Status == 'MC'){
$j(this).parents('tr').addClass('warning');
}
---
Anyway, if you need different custom color combinations, you can define your own CSS classes with color styles:
In header-extras.php:
Code: Select all
<style>
.custom-warning {
background-color: yellow !important;
color: red !important;
}
</style>
Inside your javascript file:
Code: Select all
if(Status == 'MC'){
$j(this).parents('tr').addClass('custom-warning');
}
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Table View Highlight
Fanatic! Works like a charm!!!
Last question:
Now this option highlights the whole row, what if I just want to highlight the single field.
For my table is called
"Move_Log"
The field I want to highlight yellow with red text is "Off_1"
Condition:
If Off_1 is = "Open Slot" (show field background yellow with red text) displaying "Open Slot"
If Off_1 is = "N/A" (show field only as background black with black text"
Can you help me bring this home???
Thank you -JS-
Last question:
Now this option highlights the whole row, what if I just want to highlight the single field.
For my table is called
"Move_Log"
The field I want to highlight yellow with red text is "Off_1"
Condition:
If Off_1 is = "Open Slot" (show field background yellow with red text) displaying "Open Slot"
If Off_1 is = "N/A" (show field only as background black with black text"
Can you help me bring this home???
Thank you -JS-
Re: Table View Highlight
Replace that one line by the following:
Note the difference at
Everything you need is on this page.
Code: Select all
$j(this).closest('td').addClass('custom-warning');
.closest('td')
instead of .parents('tr')
Everything you need is on this page.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Table View Highlight
I'll give it shot thanks!