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

      0  

    Default How to add a "blank" entry to a ComboBox?

    How to add a "blank" entry to a ComboBox?


    I want to have a ComboBox that is not editable and has set choices from a store, but I also want them to choose nothing as a valid choice as well.

    How do I accomplish this? Ideally I'd like to have a blank entry by default, and when they click on the ComboBox, the blank entry is up top, with the other valid entries below.

    thanks!

  2. #2
    Ext User dlbjr's Avatar
    Join Date
    Oct 2007
    Location
    Cache, OK USA
    Posts
    280
    Vote Rating
    3
    dlbjr is on a distinguished road

      0  

    Default Try something llike this:

    Try something llike this:


    Try something llike this:

    Code:
    var ds = new Ext.data.JsonStore( {
         id : 'ds',
         url : 'some_url',
         root : 'data',
         fields: [ {
             name : 'item_id',
             type : 'string'
        }, {
             name : 'item_desc',
             type : 'string'
        }]
    });
     
    var r = Ext.data.Record.create([
         {name: 'item_id', mapping: 'item_id', type: 'string'},
         {name: 'item_desc', mapping: 'item_desc', type: 'string'}
    ]);
     
    ds.on('load', function() {
         var r = new Record({
              item_id: '0',
              item_desc: '-----'
         });
         ds.insert(0, r);
    });
    

    dlbjr - David L. Bryant Jr.

    Owner of
    dlbjr Technology Consulting
    Web2 System Developer & Consultant
    Focused on C.I. - Six Sigma - Shingo - Lean Technologies
    dlbjr.consulting@gmail.com

    Owner of:
    Attractive Graphics - "custom screen printing"
    attractivegraphicscsp@gmail.com

  3. #3
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    You are creating the record class twice.

    Use either:
    Code:
    var MyRecord = Ext.data.Record.create([
    	{name: 'item_id', mapping: 'item_id', type: 'string'},
    	{name: 'item_desc', mapping: 'item_desc', type: 'string'}
    ]);
    var ds = new Ext.data.JsonStore( {
    	id: 'ds',
    	url: 'some_url',
    	root: 'data',
    	fields: MyRecord
    	listeners: {
    		load: function() {
    			var r = new MyRecord({
    				item_id: '0',
    				item_desc: '-----'
    			});
    		ds.insert(0, r);
    	}
    });
    or
    Code:
    var ds = new Ext.data.JsonStore( {
    	id: 'ds',
    	url: 'some_url',
    	root: 'data',
    	fields: [
    		{name: 'item_id', mapping: 'item_id', type: 'string'},
    		{name: 'item_desc', mapping: 'item_desc', type: 'string'}
    	],
    	listeners: {
    		load: function() {
    			var r = new (ds.recordType)({
    				item_id: '0',
    				item_desc: '-----'
    			});
    			ds.insert(0, r);
    		}
    	}
    });

  4. #4
    Ext User
    Join Date
    Feb 2008
    Posts
    49
    Vote Rating
    0
    ClemsonJeeper is on a distinguished road

      0  

    Default


    So is ----- a special string to extjs? Or will it indeed use "------" as the text for the choice? Is there no way to make it blank?

  5. #5
    Ext User dlbjr's Avatar
    Join Date
    Oct 2007
    Location
    Cache, OK USA
    Posts
    280
    Vote Rating
    3
    dlbjr is on a distinguished road

      0  

    Default It is the text it will show.

    It is the text it will show.


    var r = new MyRecord({
    item_id: '0',
    item_desc: '-----'
    });

    The values '0' and '-----' can be what ever you want
    Try '' for both if you like.
    dlbjr - David L. Bryant Jr.

    Owner of
    dlbjr Technology Consulting
    Web2 System Developer & Consultant
    Focused on C.I. - Six Sigma - Shingo - Lean Technologies
    dlbjr.consulting@gmail.com

    Owner of:
    Attractive Graphics - "custom screen printing"
    attractivegraphicscsp@gmail.com

  6. #6
    Ext User dlbjr's Avatar
    Join Date
    Oct 2007
    Location
    Cache, OK USA
    Posts
    280
    Vote Rating
    3
    dlbjr is on a distinguished road

      0  

    Default Oops! Just getting the visual point accross ...

    Oops! Just getting the visual point accross ...


    Oops! Just getting the visual point accross and not paying attention.
    dlbjr - David L. Bryant Jr.

    Owner of
    dlbjr Technology Consulting
    Web2 System Developer & Consultant
    Focused on C.I. - Six Sigma - Shingo - Lean Technologies
    dlbjr.consulting@gmail.com

    Owner of:
    Attractive Graphics - "custom screen printing"
    attractivegraphicscsp@gmail.com

  7. #7
    Ext User
    Join Date
    Feb 2008
    Posts
    49
    Vote Rating
    0
    ClemsonJeeper is on a distinguished road

      0  

    Default


    I've tried '' (previous to posting this). EG, I've created an entry with a value of '' for what is displayed, but since ExtJs calculates the size of the pulldown widget by the added heights of the entries in the pulldown, it is incorrect. '' doesn't expand to a full-sized entry, just one that is like 3 or 4 pixels.

    So the empty choice exists, but it is impossible to see/click on unless you know its there. I would think the '' choice should be the same size as a choice with text in it.

  8. #8
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    You can simply fix that with a different tpl:
    Code:
    tpl: '<tpl for="."><div class="x-combo-list-item">{text:defaultValue("&nbsp;")}</div></tpl>'
    (assuming your displayField is named 'text')

  9. #9
    Ext User
    Join Date
    Feb 2008
    Posts
    49
    Vote Rating
    0
    ClemsonJeeper is on a distinguished road

      0  

    Default


    PERFECT. That did it!

    Thanks!

  10. #10
    Ext JS Premium Member
    Join Date
    Aug 2007
    Posts
    269
    Vote Rating
    0
    gotcha is on a distinguished road

      0  

    Default


    Quote Originally Posted by Condor View Post
    You can simply fix that with a different tpl:
    Code:
    tpl: '<tpl for="."><div class="x-combo-list-item">{text:defaultValue("&nbsp;")}</div></tpl>'
    (assuming your displayField is named 'text')
    If I use a '.', I get three entries, one of which is '.' .

    Question - if I change '.' to 'BLANKTEXT', how come dropdown has no entries? I get the following error "BLANKTEXT is not defined"
    PHP Code:
    var rec = new store.recordType({EMPID:'0'EMPNAME:'BLANKTEXT'});
    store.add(trec);

    var 
    cb = new Ext.form.ComboBox({
            
    storethis.TableTypeStore,
            
    valueField:'EMPNAME',
            
    displayField:'EMPNAME',
            
    typeAheadtrue,
            
    mode'local',
            
    triggerAction'all',
            
    selectOnFocus:true,
            
    editable:false,
            
    tpl'<tpl for="BLANKTEXT"><div class="x-combo-list-item">{EMPNAME:defaultValue("&nbsp;")}</div></tpl>'
     
    }); 

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