[CLOSED] ComboBox Custom template for EXT 4 MVC

  1. #1

    [CLOSED] ComboBox Custom template for EXT 4 MVC

    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?
    Last edited by fabricio.murta; Aug 20, 2016 at 3:41 AM.
  2. #2
    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.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    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,
    Click image for larger version. 

Name:	Untitled.jpg 
Views:	1 
Size:	75.6 KB 
ID:	24729

    Thanks
    Attached Thumbnails ColorComboBox.png  
  4. #4
    Hello @Fahd!

    Cool, thanks for sharing the outcome of the issue!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] Combobox display field custom template
    By bayoglu in forum 2.x Premium Help
    Replies: 4
    Last Post: Mar 15, 2013, 5:11 PM
  2. Custom Template Column
    By QualityCode in forum 1.x Help
    Replies: 2
    Last Post: Oct 30, 2011, 12:18 AM
  3. [CLOSED] Using custom template in a ComboBox
    By mattwoberts in forum 1.x Premium Help
    Replies: 1
    Last Post: Apr 28, 2011, 4:06 PM
  4. [CLOSED] Custom Template From CodeBehind
    By Immobilmente in forum 1.x Premium Help
    Replies: 2
    Last Post: Feb 10, 2009, 10:35 AM
  5. Custom Grid Header Template
    By mathec in forum 1.x Help
    Replies: 2
    Last Post: Jan 30, 2009, 8:20 PM

Tags for this Thread

Posting Permissions