[CLOSED] ComboBox Custom template for EXT 4 MVC

Hybrid View

Previous Post Previous Post   Next Post Next Post
  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 2: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 Click image for larger version. 

Name:	ColorComboBox.png 
Views:	3 
Size:	10.7 KB 
ID:	24728  
  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 Legacy Premium Help
    Replies: 4
    Last Post: Mar 15, 2013, 4:11 PM
  2. Custom Template Column
    By QualityCode in forum 1.x Help
    Replies: 2
    Last Post: Oct 29, 2011, 11:18 PM
  3. [CLOSED] Using custom template in a ComboBox
    By mattwoberts in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 28, 2011, 3:06 PM
  4. [CLOSED] Custom Template From CodeBehind
    By Immobilmente in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 10, 2009, 9:35 AM
  5. Custom Grid Header Template
    By mathec in forum 1.x Help
    Replies: 2
    Last Post: Jan 30, 2009, 7:20 PM

Tags for this Thread

Posting Permissions