[CLOSED] Combobox with all icon MVC

  1. #1

    [CLOSED] Combobox with all icon MVC

    Hi,
    How do I populate a combobox with all EXT.Net Icons from code behind,I am unable to find example or any forum post.please help.

    I read http://forums.ext.net/showthread.php...-List-of-Icons and http://forums.ext.net/showthread.php...obox-with-Icon and try some thing bellow.but not working

    Html.X().ComboBox()
            .ID("ComboBoxAllIcons")
            .Editable(false)
            .QueryMode(DataLoadMode.Local)
            .TriggerAction(TriggerAction.All)
            .EmptyText("Select a country")
            .DisplayField("name")
            .ValueField("name")
            .FieldLabel("Country")
              
            .ForceSelection(true)
           
            .Store(Html.X().Store()
                .ID("strore1")
    
                    .Model(Html.X().Model()
                       // .IDProperty("Id")
                        .Fields(
    
                            Html.X().ModelField().Name("iconCls").Type(ModelFieldType.String),
                            Html.X().ModelField().Name("name").Type(ModelFieldType.String)
                        )
    
                    )
                
                 
                )
                
                  .ListConfig(Html.X().BoundList()
                    .ItemTpl(Html.X().XTemplate()
                    .Html(@<tpl for=".">
                    <div class="x-combo-list-item icon-combo-item {iconCls}">
                       {name}
                    </div>
                    </tpl>)
                    )
                    )
     public ActionResult Index()
            {
               
              List<string> s=  Enum.GetNames(typeof(Icon)).ToList<string>();
              var st = X.GetCmp<Store>("strore1");
              st.LoadData(s);
                return View();
            }
    Last edited by Daniil; Feb 03, 2015 at 2:11 PM. Reason: [CLOSED]
  2. #2
    https://examples2.ext.net/#/Miscella.../Icon_Summary/

    Look at the source code for that sample and it should help you with your sample.

    Once you have a sample working, please post here in the forums to share with others.
    Geoffrey McGill
    Founder
  3. #3
    Hi,
    I already have your mentioned link,but the problem is data not load in combobox,can you please assist me what I need to do ?
  4. #4
    You can review the generated JavaScript, and try to work out what's going wrong.

    Tools such as Firefox + Firebug can be very helpful with debugging JavaScript.

    How about first trying to get the sample working with a static array of objects. Once you have that working, then proceed to generating a List of Enum values.
    Geoffrey McGill
    Founder
  5. #5
    After a long time I post in this thread.I go through again https://examples2.ext.net/#/Form/ComboBox/IconCombo/ but not understand how I do this in MVC. Is there any way to get all icons in a list and then bind with combo box? please help.
  6. #6
    can any body give me some idea on this?
  7. #7
    but not understand how I do this in MVC
    Could you, please, formulate some specific statements and questions what exactly problem you are facing implementing that example in MVC? You've already built a lot of great stuff in MVC with Ext.NET, so I am not sure how exactly I could help in this case.

    Is there any way to get all icons in a list and then bind with combo box? please help.
    Yes, there should be a way. As far as I can see Geoffrey said a couple of tips. Please clarify have you tried any? What is the result?
    Last edited by Daniil; Jan 23, 2015 at 10:40 AM.
  8. #8
    Hi,
    I do bellow code

    View

    <div>
            @X.ResourceManager()
            @(Html.X().ComboBox()
            .ID("ComboBoxAllIcons")
            .Editable(false)
            .QueryMode(DataLoadMode.Local)
            .TriggerAction(TriggerAction.All)
            .EmptyText("Select a country")
            .DisplayField("name")
            .ValueField("name")
            .FieldLabel("Country")
              
            .ForceSelection(true)
           
            .Store(Html.X().Store()
                .ID("strore1")
    
                    .Model(Html.X().Model()
                       // .IDProperty("Id")
                        .Fields(
    
                            Html.X().ModelField().Name("iconCls").Type(ModelFieldType.String),
                            Html.X().ModelField().Name("name").Type(ModelFieldType.String)
                        )
    
                    )
                .Proxy(X.AjaxProxy()
                        .Url(Url.Action("geticons")))
                 
                )
                
                  .ListConfig(Html.X().BoundList()
                    .ItemTpl(Html.X().XTemplate()
                    .Html(@<tpl for=".">
                    <div class="thumb-wrap" id="{name}">
    						<div class="thumb"><img src="{iconCls}" title="{name}">&nbsp;{name}</div>
    					</div>
                    </tpl>)
                    )
                    )
                    )
        </div>
    Controller

     public ActionResult Index()
            {
       
    
                return View();
            }
    
            public StoreResult geticons()
            {
               
                List<string> icons = Enum.GetNames(typeof(Icon)).ToList<string>();
    
                icons.Remove("None");
    
                List<object> data = new List<object>(icons.Count);
    
                icons.ForEach(icon => data.Add(
                    new
                    {
                        name = icon,
                        iconCls = GetIconClassName(((Icon)Enum.Parse(typeof(Icon), icon)))
                    }
                ));
    
    
                return this.Store(data);
                
            }
    
            public string GetIconClassName(Icon icon)
            {
                ResourceManager.RegisterGlobalIcon(icon);
                return ResourceManager.GetIconClassName(icon);
            }
    but not working ,only one Item add to combo box without name and image.can you please correct me?
  9. #9
    Hello,

    If you view the html source of this page, is every single icon location rendered? If you are using ResourceManager.RegisterGlobalIcon, then I think that will add a path config for each icon directly into the page source. There are 1700+ icons, so that is going to add a lot of bloat to your page.

    I think you might want to investigate a different approach.
    Geoffrey McGill
    Founder

Similar Threads

  1. ComboBox Icon cannot show
    By Vinci in forum 2.x Help
    Replies: 0
    Last Post: Jun 14, 2013, 3:28 AM
  2. [FIXED] [2.1] Combobox Icon Alignment
    By prost in forum Bugs
    Replies: 1
    Last Post: Nov 24, 2012, 5:30 AM
  3. Combobox with Icon
    By Maia in forum 1.x Help
    Replies: 7
    Last Post: Sep 03, 2010, 5:32 PM
  4. Replies: 5
    Last Post: Mar 05, 2010, 3:15 PM

Tags for this Thread

Posting Permissions