Ext.getCmp is not working

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Ext.getCmp is not working

    I am trying to create a combobox dynamically on page load, But while accessing the component in Javascript function "selecttop" by id, it is not returning the component. It always returns undefined. Please find below the code.

    HTML :

    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat ="server" />
    <ext:Button ID="btnTest" runat="server" Text="Test" width="100" OnClientClick="selecttop();" ></ext:Button>

    <script type="text/javascript">
    var selecttop = function () {

    var cnt = Ext.getCmp('cmbItem');
    var store = cnt.getStore();

    cnt.setValue(store.getAt(0).get('ItemID'));
    };
    </script>
    </form>

    Code :

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim cmbItem As New Ext.Net.ComboBox

    cmbItem.ID = "cmbItem"
    cmbItem.Width = "200"
    cmbItem.TypeAhead = True
    cmbItem.ForceSelection = True
    cmbItem.QueryMode = Ext.Net.DataLoadMode.Local
    cmbItem.TriggerAction = Ext.Net.TriggerAction.All
    cmbItem.DisplayField = "ItemTitle"
    cmbItem.ValueField = "ItemID"

    Me.Controls.Add(cmbItem)

    LoadItem(cmbItem)

    End Sub

    Sub LoadItem(ByVal cnt As Ext.Net.ComboBox)

    Dim store As New Ext.Net.Store
    Dim model As New Ext.Net.Model

    model.Fields.Add("ItemID")
    model.Fields.Add("ItemTitle")

    store.Model.Add(model)
    store.DataSource = New Object() {
    New Object() {"1", "Item 1"},
    New Object() {"2", "Item 2"},
    New Object() {"3", "Item 3"},
    New Object() {"4", "Item 4"},
    New Object() {"5", "Item 5"}
    }

    cnt.Store.Add(store)
    store.Listeners.Load.Handler = "selecttop();"

    End Sub
    Last edited by ksaadain; Nov 07, 2017 at 1:52 PM.

Similar Threads

  1. [CLOSED] CardLayout and Ext.getCmp
    By Edgar in forum 4.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 07, 2016, 11:35 PM
  2. Replies: 1
    Last Post: May 18, 2016, 6:45 AM
  3. [CLOSED] App vrs getCmp
    By Z in forum 3.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 10, 2015, 10:16 PM
  4. X.GetCmp and FileUploadField
    By josecano in forum 1.x Help
    Replies: 2
    Last Post: May 01, 2013, 8:56 AM
  5. Ext.getCmp() not working in UserControl
    By ontiv in forum 2.x Help
    Replies: 10
    Last Post: Oct 16, 2012, 8:54 AM

Tags for this Thread

Posting Permissions