[CLOSED] gridpanel with combobox column editor

  1. #1

    [CLOSED] gridpanel with combobox column editor

    Hi,

    based on this example (https://examples1.ext.net/#/GridPane..._DirectMethod/)

    I just changed the last column "Last Update" to "Ext.Net.Column" and the column.editor I use a Ext.Net.Combobox that I populate using an enum, like this.

    public enum MyType
        {
            Type0 = 0,
            Type1 = 1,
            Type2 = 2,
        }
    
    protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                MyCombobox.Items.Add(new Ext.Net.ListItem("Value Zero", MyType.Type0.ToString()));
                MyCombobox.Items.Add(new Ext.Net.ListItem("Value One", MyType.Type1.ToString()));
                MyCombobox.Items.Add(new Ext.Net.ListItem("Value Two", MyType.Type2.ToString()));
            }
        }
    But, at the grid, the column value is the value of my enum and not my description.

    Click image for larger version. 

Name:	erro.png 
Views:	372 
Size:	42.2 KB 
ID:	3637

    What I'm doing wrong?
    Last edited by Daniil; Dec 30, 2011 at 6:52 PM. Reason: [CLOSED]
  2. #2
    Hi,

    You should set up a respective Renderer for Column, like the Department one here:
    https://examples1.ext.net/#/GridPane...Field_Mapping/
  3. #3
    Based on example you sent to me, I created this javascript code

    var renderCombo = function (value) {
                var r = "";
                
                for(var i=0;i< MyCombobox.getStore().data.items.length;i++)
                {
                    var item = MyCombobox.getStore().data.items[i];
                    if(item.data.value == value)
                    {
                        r = item.data.text;
                        break;
                    }
                }
                
                return r;
            }
    I'm not using a "store" to store data.

    There is a smart way to do that or the way I did is good for?
  4. #4
    Yes, your code is correct, but I would suggest to use the Store's API.

    Example
    var myRenderer = function (value) {
        var store = ComboBox1.getStore(),
            index = store.find("value", value),
            r = store.getAt(index);
    
        if (Ext.isEmpty(r)) {
            return "";
        }
                
        return r.data.text;
    };
  5. #5
    Thanks!

    Much easier.

    Works fine for me :)

    happy new year.
  6. #6
    Happy New Year!

Similar Threads

  1. Replies: 14
    Last Post: Aug 18, 2016, 1:57 AM
  2. Replies: 1
    Last Post: Feb 19, 2012, 1:07 PM
  3. Replies: 2
    Last Post: May 05, 2011, 10:16 AM
  4. [CLOSED] [1.0] ComboBox Editor bound to another Column
    By edigital in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Sep 06, 2010, 12:29 PM
  5. Replies: 3
    Last Post: Mar 30, 2009, 1:53 PM

Posting Permissions