Hi
I prepared toolbar:
@foreach (var Item in @myBar)
{
Text=@(Item.Text) TooltipText=@(Item.TooltipText)
HtmlAttributes=@(Item.HtmlAttributes)>
}
and set background color:
ToolbarItem sItem;
Dictionary
string c;
foreach (InfoRec infoRec in infoList)
{
sItem = new ToolbarItem();
sItem .Text = infoRec.Code;
sItem .TooltipText = infoRec.Name;
sItem .Id = infoRec.Code;
c = "background: " + infoRec.Color + "!important;";
d = new Dictionary
{
{ "style" , c }
};
sItem .HtmlAttributes = d;
myBar.Add(sItem );
}
It works only for background. How to set separate each button's color?
Regards
Maciej
Hi Maciej,
To get the font color of the button, you can use the default CssClass="@Item.CssClass" property of the toolbar and apply the CSS to it like the below code snippet.
|
List<ToolbarData> ToolbarItems = new List<ToolbarData>() { new ToolbarData { Text = "Cut", TooltipText = "Cut", CssClass = "primary" }, new ToolbarData { Text = "Copy", TooltipText = "Copy", CssClass = "secondary" }, }; |
|
<style>
. primary { background-color: orange; } .primary .e-tbar-btn-text{ color: green !important; } .secondary{ background-color: yellow; } .secondary .e-tbar-btn-text{ color: red !important; }
</style> |
Output:
|
|
Kindly try the attached sample and let us know if this meets your requirement.
Regards,
Ruksar Moosa Sait
Thank you for answer.
You set the background of the buttons and the color of the font.
Can I also set the button color?
And can I do it dynamically - creating a color in the program, not in a style file?
Regards,
Maciej
Hi Maciej,
No. The button color can be set only through the CSS classes and not possible programmatically.
Regards,
Ruksar Moosa Sait