I'd want to pimp up my browse form a little by showing a status icon. Is there a function to load a png from the server and show it in a browse column in front of a text?
Something like in column Status:
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
show a status icon in a browse
-
- Posts: 78
- Joined: Thu Nov 01, 2018 6:01 am
show a status icon in a browse
You do not have the required permissions to view the files attached to this post.
-
- nuBuilder Team
- Posts: 4307
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 448 times
- Contact:
Re: show a status icon in a browse
Here's a function to add a status icon before the text in a column. It uses font awesome icons ( https://fontawesome.com/v4.7.0/icons/ )
-> Add this JavaScript code to your form's Custom Code field:
-> Change the status descriptions, icons, colors in statusArr if necessary.
// Example: Add a status icon in the first column.
-> Add this JavaScript code to your form's Custom Code field:
-> Change the status descriptions, icons, colors in statusArr if necessary.
Code: Select all
var statusArr = [
{status:"Pending",class:"fa fa-clock-o",color:"#f1c40f"}, // orange
{status:"Completed",class:"fa fa-check-circle",color:"#2ecc71"}, // green
{status:"Cancelled",class:"fa fa-ban",color:"#e74c3c"}, // red
{status:"New",class:"fa fa-circle-o",color:"#707070"}, // grey
{status:"In progress",class:"fa fa-spinner",color:"#3498db"} // blue
]
function addStatusIconFA(col) {
$("[data-nu-column='" + col + "']").each(function(index) {
var status = $(this).html();
var index = statusArr.findIndex(x => x.status === status);
var _class = statusArr[index].class;
var color = statusArr[index].color;
$(this).prepend('<i class="' + _class + '" aria-hidden="true" style="font-size:medium;color:' + color + ';"></i> ');
})
}
Code: Select all
if (nuFormType() == 'browse') {
addStatusIconFA(0);
}
You do not have the required permissions to view the files attached to this post.
-
- Posts: 78
- Joined: Thu Nov 01, 2018 6:01 am
Re: show a status icon in a browse
Kevin, your my hero! This was exactly what I was looking for. Thank you so much !