1. #1
    Ext User
    Join Date
    Feb 2008
    Posts
    40
    Vote Rating
    0
    technicaltitch is on a distinguished road

      0  

    Default Can't get forceSelection:false working in an EditorGrid

    Can't get forceSelection:false working in an EditorGrid


    Pleease help...! I've got a combo in a grid using an HTML SELECT, yet if I type something into the combo that isn't in the list, as soon as the cursor leaves the box (by tabbing, pressing enter or clicking elsewhere), the value reverts to the previously selected value.

    The column model definition:
    Code:
    {
        dataIndex: 'ShopCode',
        header:"Shop Code",
        id:    'classShopCode',
        locked: false,
        sortable: true,
        resizable: true,
        width: 12,
        editor:  =  new Ext.form.ComboBox({
                    allowBlank: false,
                    typeAhead: true,
                    triggerAction: 'all',
                    transform:'ShopCode',
                    forceSelection: false,
                    lazyRender:true,
                    resizable: true
                })
    }
    The combo:
    Code:
    <select name="cboShop" id="ShopCode" style="display: none;">
    <option value="shop1">shop1</option>
    <option value="shop2">shop2</option></select>
    I'm at my wits end...HUGE thank you for any time spent!
    Chris
    Last edited by technicaltitch; 14 Mar 2008 at 12:36 PM. Reason: clearer, typo

  2. #2
    Ext JS Premium Member Steffen Hiller's Avatar
    Join Date
    Mar 2008
    Posts
    767
    Vote Rating
    23
    Steffen Hiller will become famous soon enough Steffen Hiller will become famous soon enough

      0  

    Default


    Hey technicaltitch,

    here's a little hacky solution:

    Code:
        var CustomComboBox = Ext.extend(Ext.form.ComboBox, {
                getValue: function() {
                  return this.el.dom.value;
                }
            });
    
    ...
    
    {
        dataIndex: 'ShopCode',
        header:"Shop Code",
        id:    'classShopCode',
        locked: false,
        sortable: true,
        resizable: true,
        width: 12,
        editor:  =  new CustomComboBox({
                    allowBlank: false,
                    typeAhead: true,
                    triggerAction: 'all',
                    transform:'ShopCode',
                    forceSelection: false,
                    lazyRender:true,
                    resizable: true
                })
    }
    Well, it's hacky, but it's working for me now. :-)

    The reason for not passing the new value to the grid is, that the combobox generates two input fields in the dom, one hidden input field where it maintains the selected value (this hidden field is used to post the value and not the display text to the server if used in a form) and one text input field, where you actually type in your new value. Well, when you finish editing your grid cell, the getValue method of your Combobox gets called, which gets the value out of the hidden field (which holds the value of the last combobox selection).

    Well, let me know if you'll find a better solution based on my solution.

    Regards,
    Steffen

  3. #3
    Ext User
    Join Date
    Feb 2008
    Posts
    40
    Vote Rating
    0
    technicaltitch is on a distinguished road

      0  

    Default


    Will do but that's a massive relief - thank you very much! (Works a treat!)

  4. #4
    Ext User denkoo's Avatar
    Join Date
    Jan 2008
    Location
    Paris
    Posts
    124
    Vote Rating
    0
    denkoo is on a distinguished road

      0  

    Thumbs up thanks for this solution... great works !

    thanks for this solution... great works !


    I suggest another INIT :

    PHP Code:
    //fix COMBO Editable in Ext2.02
    Ext.override(Ext.form.ComboBox, {
        
    getValue: function() {
            return 
    this.el.dom.value;
        }
    }); 
    With this code, is not necessary to change name's layout and when EXTJS update and fix this problem, remove this line on your code

  5. #5
    Ext User denkoo's Avatar
    Join Date
    Jan 2008
    Location
    Paris
    Posts
    124
    Vote Rating
    0
    denkoo is on a distinguished road

      0  

    Thumbs up I have problem again with COMBO with NumberField and some text in displayField

    I have problem again with COMBO with NumberField and some text in displayField


    If my value is number and I have text on
    displayField, I have some trouble, So I patch again this code :


    PHP Code:
    //fix COMBO Editable in Ext2.02
    Ext.override(Ext.form.ComboBox, {
        
    getValue: function() {
            if(
    this.selectedIndex==-1) {
                return 
    this.el.dom.value;
            }
            else {
                return 
    this.store.getAt(this.selectedIndex).data[this.valueField];
            }
        }
    }); 

  6. #6
    Ext JS Premium Member Steffen Hiller's Avatar
    Join Date
    Mar 2008
    Posts
    767
    Vote Rating
    23
    Steffen Hiller will become famous soon enough Steffen Hiller will become famous soon enough

      0  

    Lightbulb


    Hey denkoo,

    thanks for your solutions! I wasn't aware of the Ext.override method.

    I was looking in the source code again to understand the original getValue implementation better.
    Here it is:
    Code:
        getValue : function(){
            if(this.valueField){
                return typeof this.value != 'undefined' ? this.value : '';
            }else{
                return Ext.form.ComboBox.superclass.getValue.call(this);
            }
        }
    Well, I found out that when calling Ext.form.ComboBox.superclass.getValue.call(this); it returns the same value as this.el.dom.value, which is the value we want.
    Well, investigation on the valueField, I found this description in the documentation:

    valueField : String
    The underlying data value name to bind to this ComboBox (defaults to undefined if mode = 'remote' or 'value' if transforming a select) Note: use of a valueField requires the user to make a selection in order for a value to be mapped.
    So setting valueField: '' in the config won't work, since we use a transforming here.
    Well, then I was thinking, that the developer should be able to decide via the forceSelection option, if the user is required to make a selection or not.

    So I came up with the following solution:

    Code:
    Ext.override(Ext.extend(Ext.form.ComboBox, {
      getValue: function() {
        if(this.valueField && this.forceSelection){
            if (typeof this.value != 'undefined'){
              return this.value;
            }
        }
        return Ext.form.ComboBox.superclass.getValue.call(this);
      }
    });
    So if you set forceSelection to true, it will return the value of the last selection. If you set forceSelection to false, it will return the value that the user entered into the ComboBox.
    I think that's a more Extjs-ish solution.
    What do you think?

    Cheers,
    Steffen

    P.S. Not sure if this is working with your NumberField problem you described in the previous post. But the code could be adjusted as well.

  7. #7
    Ext User denkoo's Avatar
    Join Date
    Jan 2008
    Location
    Paris
    Posts
    124
    Vote Rating
    0
    denkoo is on a distinguished road

      0  

    Red face Great Steffen

    Great Steffen


    You are my Master )))

    I'm simple amateur who try to resolve all problem appear on my app !

    you analyse seem to be perfect on my point of view. I try to implement your solution on my app and watch to adapt you patch for my numeric particular problem )) AnyWay you are on true when You take care on option forceSelection and maybe in this patch we forget other implication of code... I don't understand "Extjs-ish" abreviation but I believe that you want to say that this job is for core Extjs's developper, and again I'm agree with you )) and since this time, is Important that our application work fine )

    good day

    laurent

    Nota : All the code of my apps can be download on thread
    http://extjs.com/forum/showthread.php?t=26401
    Hope this code help all who's begin like me on ExtJS ))

  8. #8
    Sencha User genius551v's Avatar
    Join Date
    Mar 2007
    Posts
    287
    Vote Rating
    0
    genius551v is on a distinguished road

      0  

    Default


    Hello, i m interesting in your solutions.

    i have that:
    PHP Code:
    Ext.ux.textFieldWithRemoteSuggest = function(config) {
        
    config.hideTrigger true;
        
    config.forceSelection false;
        
    config.minChars 0;
        
    config.lazyRender true;

        if(
    config.mode == 'remote'){
            
    config.triggerAction 'all';
            
    config.allTimeStoreLoad true;

            
    config.store = new Ext.data.Store({
                
    proxy: new Ext.data.HttpProxy({
                    
    urlconfig.proxyUrl,
                    
    method'POST'
                
    }),
                
    reader: new Ext.data.JsonReader({
                    
    root'rows',
                    
    totalProperty'totalCount',
                    
    id'id'
                
    }, config.map)
            });
        }

        if(
    config.params){
            
    config.store.baseParams config.params;
        };

        
    Ext.ux.textFieldWithRemoteSuggest.superclass.constructor.call(thisconfig);
    };

    Ext.extend(Ext.ux.textFieldWithRemoteSuggestExt.form.ComboBox, {
        
    initComponent: function(){
            
    Ext.ux.textFieldWithRemoteSuggest.superclass.initComponent.call(this);
        },
        
        
    getValue: function(){
            if(
    this.valueField && this.forceSelection){
                if (
    typeof this.value != 'undefined'){
                  return 
    this.value;
                }
            }
            return 
    Ext.form.ComboBox.superclass.getValue.call(this);
        },
        
        
    doQuery : function(qforceAll){
            if(
    === undefined || === null){
                
    '';
            }
            if(
    != ''){ //if delete text initial or is a new so clear and hide the result list
                
    var qe = {
                    
    queryq,
                    
    forceAllforceAll,
                    
    combothis,
                    
    cancelfalse
                
    };
                if(
    this.fireEvent('beforequery'qe)===false || qe.cancel){
                    return 
    false;
                }
                
    qe.query;
                
    forceAll qe.forceAll;
                if(
    forceAll === true || (q.length >= this.minChars)){
                    if(
    this.lastQuery !== || this.allTimeStoreLoad == true){
                        
    this.lastQuery q;
                        if(
    this.mode == 'local'){
                            
    this.selectedIndex = -1;
                            if(
    forceAll){
                                
    this.store.clearFilter();
                            }else{
                                
    this.store.filter(this.displayFieldq);
                            }
                            
    this.onLoad();
                        }else{
                            
    this.store.baseParams[this.queryParam] = q;
                            
    this.store.load({
                                
    paramsthis.getParams(q)
                            });
                            
    this.expand();
                        }
                    }else{
                        
    this.selectedIndex = -1;
                        
    this.onLoad();
                    }
                }
            }else{
                
    this.onEmptyResults();
            }
        }
    }); 
    but dont work, select the firts in the result list

    can you help me please?

  9. #9
    Ext JS Premium Member Steffen Hiller's Avatar
    Join Date
    Mar 2008
    Posts
    767
    Vote Rating
    23
    Steffen Hiller will become famous soon enough Steffen Hiller will become famous soon enough

      0  

    Question


    Hey genius551v,

    sorry for my late reply!
    Have you solved this problem meanwhile? Does your problem relate to this thread? Can you describe it a little more? Maybe it would be better to open a new thread to keep this forum organized?

    Regards,
    Steffen

  10. #10
    Ext User
    Join Date
    Feb 2008
    Posts
    40
    Vote Rating
    0
    technicaltitch is on a distinguished road

      0  

    Default


    denkoo your help helped me solve a related problem whereby I couldn't blank a populated drop-down (even if allowBlank=true and forceSelection=false - a UI bug) - posted here below the ExtJS bug report.

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar