molecule-man / ExtJsListbox

Listbox widget (ExtJs 4.x)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Thank you for this, exactly what I needed

qharlie opened this issue · comments

Here is a simple getValue() function for it , it might be useful. I also have a modified version that takes a name,value pair and returns the value part for getValue() if anyone wants it.

    getValue: function ()
    {
        var me = this;
        var items = Ext.dom.Query.select('.x-listbox .x-item-selected');
        if ( !items.length) return "";
        else if (items.length === 1 && me.multiSelect === false) return items[0].innerHTML ;
        else if ( items.length >= 1 )
        {
            var ret = [];
            Ext.each(items, function (item)
            {
                ret.push(item.innerHTML);
            });
            return ret;
        }
    }

There is no need to mess with innerHTML if you want to retrieve selected record. You can use view's built-in selModel:

var selectedRecords = listBox.selModel.getSelection();

See this script for example (#button1to2 click event handler).

I missed that somehow :S. Anyway I've added getValue and getRawValue methods to it and added also wrapped it in a field.Labelable for use in form.Panel 's here https://github.com/qbert65536/extjs4x-contrib/ .

Are there any other contrib items you have ? I was going to make a simple grid plugin for making the first column a hyperlink and firing a doubleclick event, maybe we should combine repos ?