Reputation: 141
I'm saving a color from the user and saving it in SQL Server. And those color should be shown on my grid after retrieving from SQL Server.
From my code it shows only the hex value like #ff0000
, but I want to show that color in a box (or anything) to the user without the hex value.
How can I show this?
I searched everywhere but I couldn't find one.
Here is my code used to append the grid
$('<tr>' +
'<td>' + item.Name + '</td>' +
'<td>' + item.Color + '</td>' +
//'<td><span title="' + item.Description + '" data-toggle="tooltip">' + desc + '</span></td>' +
'<td><input type="checkbox" disabled="true" ' + checked + '/></td>' + '<td><input type="checkbox" disabled="true" ' + checked + '/></td>'+
'<td class="text-right">' +
'<a href="#" data-id="' + item.Id + '" class="btn btn-sm btn-dark-rgba btnEdit" title="Edit" data-toggle="tooltip" style="margin-right:5px;">' +
'<span class="fa fa-pencil"></span>' +
'</a>' +
'<a href="#" data-href="/functionstatus/delete/' + item.Id + '" class="btn btn-sm btn-dark-rgba call-popup-model-delete btnDelete" title="Delete" data-toggle="tooltip">' +
'<span class="fa fa-trash-o"></span>' +
'</a>' +
'</td>' +
'</tr>').appendTo($('#grid'));
Upvotes: 0
Views: 54
Reputation: 91
Accoring to https://www.w3schools.com/tags/att_td_bgcolor.asp this should do what you want to do
'<td bgcolor="' + item.Color + '"></td>'
Upvotes: 1