PDA

View Full Version : [CLOSED] ComboBox Custom template for EXT 4 MVC



Fahd
Aug 10, 2016, 9:55 PM
Hi Support,

I've color comboBox and I want to change background color based on value. I've found WebForm example like below,


<ext:ComboBox runat="server">
<Items>
<ext:ListItem Text="Red" Value="FF0000" />
<ext:ListItem Text="Green" Value="008000" />
<ext:ListItem Text="Blue" Value="9FD2EC" />
</Items>
<Template>
<Html>
<tpl for=".">
<h1 style="color:{value}">{text}</h1>
</tpl>
</Html>
</Template>
</ext:ComboBox>

How do I implement template like that for MVC Razor?

fabricio.murta
Aug 11, 2016, 8:53 PM
Hello @Fahd!

You didn't point where you found this code snippet but it does not work for WebForms as you provided, likewise it will not work in Razor syntax as well.

Fahd
Aug 19, 2016, 10:42 PM
I was able to do that with ListConfig following way,


Html.X().ComboBox().EmptyText("Select Color").Items(ViewBag.ColorList).FieldLabel("Color")
.ListConfig(
Html.X().BoundList().ItemTpl(
Html.X().XTemplate().Html("<div><span>{field2}</span><span style='float: right; width: 60px; height: 13px; margin: 4px; display: inline-block; border: 1px solid rgba(0, 0, 0, .2); background-color:{field1};'></span></div>"))
)

Which produce following,
24729

Thanks

fabricio.murta
Aug 20, 2016, 3:41 AM
Hello @Fahd!

Cool, thanks for sharing the outcome of the issue!