Results 1 to 3 of 3

Thread: how to set selectfiel selected value active?

  1. #1
    Sencha User
    Join Date
    Nov 2013
    Posts
    49
    Answers
    1

    Default how to set selectfiel selected value active?

    i have a picker/selectfield , based on selection in previuos view i am show/hiding some containers.
    but after changing the value (cubicon/list) again if i come back to this view from other view it should show the previous selected value.

    please help me out!!

    Code:
    						{xtype: 'selectfield',
    						id: 'SelectItem',
    						cls: 'nav_select',
    						itemId: 'SelectItem',
    						usePicker : true,
    						name: 'theme',
    						placeholder: 'please Select',
    						options: [
    						{
    							text: '-',
    							value: 'select'
    						},
    						{
    							text: 'Cubicon',
    							value: 'Cubicon'
    						},
    						{
    							text: 'List',
    							value: 'List'
    						}
    						],
    						
    						listeners: {
    							change: function(field, newValue){
    								 var selectItem = Ext.ComponentQuery.query('#SelectItem')[0].getValue();
    									console.log(newValue);
    									
    									if(selectItem == 'List'){
    										Ext.ComponentQuery.query('main > #selectdefault')[0].setHidden(true);
    										Ext.ComponentQuery.query('main > #selectcustom')[0].setHidden(false);
    										
    									}
    									else if(selectItem == 'Cubicon'){
    										Ext.ComponentQuery.query('main > #selectdefault')[0].setHidden(false);
    										Ext.ComponentQuery.query('main > #selectcustom')[0].setHidden(true);
    									}
    									
    									// else {
    									// Ext.ComponentQuery.query('main > #whitebox')[0].setHidden(false);
    									// Ext.ComponentQuery.query('main > #blackbox')[0].setHidden(true);
    
    
    
    
    									// }
    									
    									
    							}
    						},
    						flex: 2
    						}

  2. #2
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    4,108
    Answers
    342

    Default

    I'm not sure if I am following you but you can set the value of the selectfield by calling its setValue method.
    See the following fiddle: https://fiddle.sencha.com/#fiddle/3sj
    Please beautify your code before posting.
    Get more personalized support via a support subscription.

    Need more help with your app? Hire Sencha Services [email protected]

    When posting code, please use BBCode's CODE tags.

    Need to include a test case use:
    The official Sencha Fiddle

  3. #3
    Sencha User
    Join Date
    Nov 2013
    Posts
    49
    Answers
    1

    Default Hi fmoseley,

    My requirement is,
    What ever the dropdown value i selected it should store in localstorage. Even refresh it should still show the selected value only.

    {
    xtype: 'selectfield',
    cls: 'customselectfield',
    inputCls: 'selectfield',
    name: 'fromaccount',
    usePicker : true,
    placeHolder: 'please Select',
    valueField : 'value',
    autoSelect : false,
    itemId: 'SelectItem',
    id: 'SelectItem',

    options: [
    {
    text: 'Cubicony',
    value: 'cubicon'
    },
    {
    text: 'Listy',
    value: 'list'
    }
    ],

    }

    listeners: {
    change: function(field, newValue){}
    ???? HOW STORE SLECTED VALUE.. KEEP SELECTED AFTER REFRESH..???
    }

    Please suggest me.

Posting Permissions

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