2012-06-30 7 views
5

सेन्चा टच 2 सीखने की कोशिश कर रहा है और मुझे लगता है कि किसी चुनिंदा क्षेत्र में डिफ़ॉल्ट चयनित विकल्प को सेट करने का तरीका नहीं लगता है। यहाँ मैं अपने main.js ध्यान में रखते हुए की कोशिश की है है:सेन्चा टच 2 का चयन विकल्प चुनिंदा विकल्प

Ext.define('mobile-form.view.Main', { 
    extend: 'Ext.Container', 
    requires: [ 
     'Ext.TitleBar', 
     'Ext.form.FieldSet', 
     'Ext.field.Select', 
    ], 
    config: { 
     fullscreen: true, 
     layout: 'vbox', 
     items: [ 
       { 
        xtype: 'titlebar', 
        docked: 'top', 
        cls: 'titlebar' 
       }, 
       { 
        xtype: 'panel', 
        scrollable: 'vertical', 
        cls: 'form_container', 
        flex: 1, 
        items: [ 
         { 
          xtype: 'fieldset', 
          items: [ 
           { 
            xtype: 'selectfield', 
            label: 'Desired Policy Type', 
            labelWidth: 'auto', 
            name: 'test', 
            options: [ 
             {text: 'Test 1', value: '1'}, 
             {text: 'Test 2', value: '2'}, 
             // this doesn't work 
             {text: 'Test 3', value: '3', selected: true}, 
             {text: 'Test 4', value: '4'} 
            ], 
            listeners: { 
             // this doesn't work 
             painted: function() { 
              console.log(this); 
              this.select(3); 
             } 
            } 
           } 
          ] 
         } 
        ] 
       } 
      ] 
    } 
}); 

मैं बजाय प्रतीक्षा करने के लिए जब तक आवेदन ही तैयार है की जरूरत है? कुछ इस तरह:

Ext.application({ 
    name: 'mobile-form', 

    requires: [ 
     'Ext.MessageBox' 
    ], 

    views: ['Main'], 

    icon: { 
     '57': 'resources/icons/Icon.png', 
     '72': 'resources/icons/Icon~ipad.png', 
     '114': 'resources/icons/[email protected]', 
     '144': 'resources/icons/[email protected]' 
    }, 

    isIconPrecomposed: true, 

    startupImage: { 
     '320x460': 'resources/startup/320x460.jpg', 
     '640x920': 'resources/startup/640x920.png', 
     '768x1004': 'resources/startup/768x1004.png', 
     '748x1024': 'resources/startup/748x1024.png', 
     '1536x2008': 'resources/startup/1536x2008.png', 
     '1496x2048': 'resources/startup/1496x2048.png' 
    }, 

    launch: function() { 
     // Destroy the #appLoadingIndicator element 
     Ext.fly('appLoadingIndicator').destroy(); 

     // Initialize the main view 
     Ext.Viewport.add(Ext.create('mobile-form.view.Main')); 
    }, 

    onUpdated: function() { 
     Ext.Msg.confirm(
      "Application Update", 
      "This application has just successfully been updated to the latest version. Reload now?", 
      function(buttonId) { 
       if (buttonId === 'yes') { 
        window.location.reload(); 
       } 
      } 
     ); 
    }, 
    onReady: function() { 
     {SomeWayToTargetElement}.select(2); 
    } 
}); 

यदि ऐसा है तो मैं अपने विचारों में तत्वों पर एक पहचानकर्ता सेट करना ताकि मैं उन्हें आवेदन के onReady घटना के भीतर लक्ष्य कर सकते हैं?

किसी भी सहायता की बहुत सराहना की जाती है। अब तक प्यार सेन्चा। उनके दस्तावेज़ महान हैं। बस उन दस्तावेज़ों के अधिक उदाहरण ढूंढने की आवश्यकता है और मैं स्याही हम सब बहुत बेहतर हो जाएगा। : पी

उत्तर

5

बस selectfield के config पर value विशेषता का उपयोग:

Ext.create('Ext.form.Panel', { 
    fullscreen: true, 
    items: [ 
     { 
      xtype: 'fieldset', 
      title: 'Select', 
      items: [ 
       { 
        xtype: 'selectfield', 
        label: 'Choose one', 
        value:'second', 
        options: [ 
         {text: 'First Option', value: 'first'}, 
         {text: 'Second Option', value: 'second'}, 
         {text: 'Third Option', value: 'third'} 
        ] 
       } 
      ] 
     } 
    ] 
}); 

तुम भी, श्रोताओं के साथ यह कर सकते हैं की तरह अपने

Ext.create('Ext.form.Panel', { 
    fullscreen: true, 
    items: [ 
     { 
      xtype: 'fieldset', 
      title: 'Select', 
      items: [ 
       { 
        xtype: 'selectfield', 
        label: 'Choose one', 
        listeners:{ 
         initialize:function(){ 
          this.setValue('second'); 
         } 
        }, 
        options: [ 
         {text: 'First Option', value: 'first'}, 
         {text: 'Second Option', value: 'second'}, 
         {text: 'Third Option', value: 'third'} 
        ] 
       } 
      ] 
     } 
    ] 
}); 

आशा करने के लिए इस मदद करता है

कोशिश कर रहे थे
+0

अहह !! कैंट का मानना ​​है कि मुझे डॉक्टरों में याद आया ... बहुत बहुत धन्यवाद। –

+0

हाँ, मैं डिफ़ॉल्ट रूप से कुछ खोज रहा था या पहले वैल्यू चुना गया, लेकिन फिर मैंने इसे पाया। –

 संबंधित मुद्दे

  • कोई संबंधित समस्या नहीं^_^