Page 2 of 28 FirstFirst 123412 ... LastLast
Results 11 to 20 of 274

Thread: [2.0] Ext.ux.Multiselect/ItemSelector v3.0

  1. #11
    Sencha Premium Member tjstuart's Avatar
    Join Date
    May 2007
    Location
    Sydney, Australia
    Posts
    457

    Default

    @tidal - nice job. looks interesting. i'll look at incorporating in a future release. cheers!

  2. #12
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    NL
    Posts
    608

    Default

    Quote Originally Posted by tidal View Post

    May somebody be interested in this...
    ... if not, at least I needed it
    Can you post a screenshot of how this looks?

  3. #13
    Ext User tidal's Avatar
    Join Date
    Apr 2007
    Location
    Berlin / Germany
    Posts
    50

    Default

    @mdissel:
    hhm, ok, I
    Last edited by tidal; 13 Dec 2007 at 5:23 AM. Reason: +

  4. #14

    Default

    So I had a minor problem with the multi-select after calling the doLayout method on the formPanel. After I set the value on some form fields in my formPanel, the doLayout eventually calls getRawValue on each form component within the panel. In the case of the multi-select, this resulted in getValue getting called with the this.view still being null since onRender hasn't been called yet. I went ahead and fixed this method by checking if the view was null or not yet. Here's the minor fix:

    Code:
    getValue: function(valueField){
    	if(this.view)
    	{
    		var returnArray = [];
    		var selectionsArray = this.view.getSelectedIndexes();
    		if (selectionsArray.length == 0) {return '';}
    		for (var i=0; i<selectionsArray.length; i++) {
    			returnArray.push(this.store.getAt(selectionsArray[i]).get(((valueField != null)? valueField : this.valueField)));
    		}
    		return returnArray.join(this.delimiter);
    	}
    	else
    	{
    		return "";
    	}
    },

  5. #15
    Sencha User
    Join Date
    Nov 2007
    Posts
    7

    Default help on the ItemSelector

    Hi!

    I'm trying to put the ItemSelector on a form, When I pre-populate the fromSelector, it works fine.
    Code:

    var fromStore = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
    url: 'userMgr.shtml?action=getAllRoles'
    }),

    reader: new Ext.data.JsonReader({
    root: 'results',
    totalProperty: 'totalCount',
    id: 'id'
    }, [
    {name: 'rolename', mapping: 'rolename'},
    {name: 'rolevalue', mapping: 'rolename'}
    ])
    });
    var rolesSelector = new Ext.ux.ItemSelector({
    name: 'roles',
    fieldLabel: "selectRole",
    valueField: "rolevalue",
    dataFields: ["rolevalue", "rolename"],
    displayField: "rolename",
    toData: [],
    anchor: '90%',
    fromStore: fromStore,
    imagePath: 'resources/multiSelector',
    allowBlank: true,
    fromLegend: "toSelect",
    toLegend: "selected"
    });
    fromStore.load();
    The problem is when I load the selected data from server like below, although the values are setted correctly, the selected items are not populated to the toSelector.
    Code:
    formPanel = new Ext.form.FormPanel({
    baseCls: 'x-plain',
    labelWidth: 75,
    url:'userMgr.shtml?action=updateUser',
    reader: new Ext.data.JsonReader({
    root: 'results'
    }, ['id','username','realname','password','cellphone','email',{name: 'roles', mapping: 'roles'}]
    ),
    defaultType: 'textfield',
    items: [
    username,
    realname,
    password,
    cellphone,
    email,
    rolesSelector
    ]
    });
    formPanel.form.load({url:'userMgr.shtml?action=loadSingleUser&id='+selectedId,
    waitMsg:'Loading'});


    So I try to override the 'setValue()' in ItemSelector.
    Code:
    setValue: function(values) {
    if (!values || (values == '')) { return; }
    if (!(values instanceof Array)) { values = values.split(this.delimiter); }
    var records = [];

    for(var i=0; i<values.length; i++){
    //find the items in fromSelector
    recordIdx = this.fromMultiselect.view.store.findBy(function(record, id){
    var json = record.json;

    for(var p in json){
    if(json[p]==values[i])
    return true;
    }
    return null;
    });
    record = this.fromMultiselect.view.store.getAt(recordIdx);

    records.push(record);
    }
    if(!this.allowDup)selectionsArray = [];
    for(var i=0; i<records.length; i++){
    record = records[i];
    if(this.allowDup){
    var x=new Ext.data.Record();
    record.id=x.id;
    delete x;
    this.toMultiselect.view.store.add(record);
    }else{
    this.fromMultiselect.view.store.remove(record);
    this.toMultiselect.view.store.add(record);
    selectionsArray.push((this.toMultiselect.view.store.getCount() - 1));
    }
    }
    this.toMultiselect.view.refresh();
    this.fromMultiselect.view.refresh();
    if(this.toSortField)this.toMultiselect.store.sort(this.toSortField, this.toSortDir);
    if(this.allowDup)this.fromMultiselect.view.select(selectionsArray);
    else this.toMultiselect.view.select(selectionsArray);
    this.valueChanged(this.toMultiselect.store);
    }
    but to find that datas in 'this.fromMultiselect.view.store' are not completely loaded, I must explicitly wait a while using methods like 'while(this.fromMultiselect.view.store.getCount()==0){
    setTimeout(Ext.emptyFn, 100);
    }'

    I'm confusing about why the 'fromMultiselect.view.store' is not loaded.

    can anyone help?

    Thanks,
    Rick

  6. #16
    Sencha User
    Join Date
    Oct 2007
    Posts
    26

    Default add a selectAll method

    I don't know if it has already been discussed here but I think it would be helpful if we add a selectAll() method to the MultiSelect form field.

    Here's a snippet of code that does the job :

    Code:
        selectAll: function() {
            var selections = [];
            for (var i = 0; i < this.view.store.getTotalCount(); i++) {
                selections.push(i);
            }
            this.view.select(selections);
    	    this.hiddenField.dom.value = this.getValue();
    	    this.validate();
        },
    I added it just after the setValue method.

    Regards,
    Pierre

  7. #17
    Sencha Premium Member tjstuart's Avatar
    Join Date
    May 2007
    Location
    Sydney, Australia
    Posts
    457

    Default

    @racke - could you possibly post a working example online. it's near impossible to decipher what's going on without something to debug. also, in future post your code using the PHP code formatting button.

    @everyone else - thanks for the submissions. some good stuff there. i'm off on holidays for christmas and will return 7 January 2008. will try to have 3.1 ready for release mid January. merry christmas to all. cheers

  8. #18

    Join Date
    Aug 2007
    Location
    Romania
    Posts
    41

    Default

    Is there a way to put a Loading indicator for the multiselect field, because if used in a form, where the store returns many records, it takes time to load the data in the field, and the user doesn't know he has to wait!

    By the way how does the field validation for the itemselector work in a form?
    Thanx in advance!

  9. #19

    Default Help

    @tjstuart - How do i use the fromstore ?

    I use the same html of your but i put:
    Code:
    fromStore: test
    and
    Code:
        var test = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({
               url: perm.php?act=getAct'
            })
        });
        test.load();
    return of php:
    PHP Code:
    [["123","One Hundred Twenty Three"], ["1""One"], ["2""Two"], ["3""Three"], ["4""Four"], ["5""Five"], ["6""Six"], ["7""Seven"], ["8""Eight"], ["9""Nine"]] 
    But not show in the select....

  10. #20

    Default FromStore

    I did use the FromStore.. thanks...

Page 2 of 28 FirstFirst 123412 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •