PDA

View Full Version : Toolbar in Panel Title



VADIM
Apr 09, 2021, 3:57 PM
Hello,

Different type of panels have Title Bar.
Panel constructor has Tools property (type of List<Tool>).
I tried different ways to add a button in code behind to the Title of a GridPanel:
new GridPanel { Title="My Grid", Tools = new List<Tool>() {...
But nothing worked.

Can you please give an example?

Thanks,

Vadim

fabricio.murta
Apr 09, 2021, 8:19 PM
Hello @VADIM!

Setting the tools as a list of Tool objects should be correct. Declaring the list of tools, instead of ... as the following:



new List<Tool>()
{
new Tool()
{
Type = ToolType.Gear,
Tooltip = "Settings",
Callback = new JsFunction("Ext.toast('Adjust settings');")
},
new Tool()
{
IconCls = "x-fa fa-reply-all", // From font-awesome (https://fontawesome.com/cheatsheet)
Tooltip = "Reply",
Callback = new JsFunction("Ext.toast('Reply report');")
},
new Tool()
{
IconCls = "x-md md-icon-add-shopping-cart", // From material icons (https://fonts.google.com/icons?selected=Material+Icons)
Tooltip = "Add to cart",
Callback = new JsFunction("Ext.toast('Add it to cart');")
}
}


Works for me.

Hope this helps!

VADIM
Apr 09, 2021, 10:16 PM
Thanks Fabricio,

Your solution works great as always.
However tools not always can replace buttons.
When operation is no so obvious a button with text and icon could be more helpful.
I would say in 90% of the cases tools are good enough.

Vadim

fabricio.murta
Apr 09, 2021, 10:27 PM
Hello again, @VADIM!

Thanks for the feedback, and yes, the title bar buttons are not meant to 100% replace buttons, as they have limited functionality and different visual effects. If a full button is necessary, a toolbar would probably be your best bet.

Hope this helps!

VADIM
Apr 09, 2021, 10:33 PM
Exactly.
That's what I do.

Thanks again!
Vadim