EXT: Cannot read property 'reload' of undefined

1.3k Views Asked by At

I have a dropdown field and I am trying to reload its store on AfterRender but I receive this error:

Cannot read property 'reload' of undefined

Here is the code:

Javascript reload:

function LoadAll(){
    #{StoreFieldNames}.reload();
}

Ext Code:

Window afterRender:

<AfterRender Handler="LoadAll();" />

DropDownField editor in Gridpanel

<ext:DropDownField
     ID="DropDownField2"
     runat="server"
     FieldLabel="Field Name">
          <Component>
               <ext:GridPanel ID="FieldNameGridPanel"
                   runat="server"
                   Frame="true">
                       <Store>
                          <ext:Store ID="StoreFieldNames" runat="server" GroupField="Form" OnReadData="StoreFieldNames_ReadData">
                              <Model>
                                  <ext:Model ID="ModelFieldNames" runat="server">
                                      <Fields>
                                          <ext:ModelField Name="Form" />
                                          <ext:ModelField Name="FieldName" />
                                      </Fields>
                                  </ext:Model>
                              </Model>
                          </ext:Store>
                      </Store>
                      <ColumnModel runat="server">
                          <Columns>
                          <ext:Column runat="server" Text="Form" DataIndex="Form" Flex="6" />
                          <ext:Column runat="server" DataIndex="FieldName" Flex="6" />                                                               
                          <ext:ImageCommandColumn runat="server" Align="Center" Flex="1">
                               <Commands>
                                     <ext:ImageCommand Icon="Accept" CommandName="Pick">
                                            <ToolTip Text="Click to choose this fieldname" />
                                     </ext:ImageCommand>
                               </Commands>
                               <Listeners>
                                  <Command Handler="this.gridRef.dropDownField.setValue(record.data.FieldName);" />
                               </Listeners>

                           </ext:ImageCommandColumn>
                       </Columns>
                  </ColumnModel>
                  <View>
                      <ext:GridView ID="GridView3" runat="server" LoadMask="true" />
                  </View>

                  <SelectionModel>
                       <ext:RowSelectionModel ID="RowSelectionModel3" runat="server" Mode="Multi" />
                  </SelectionModel>

                  <Features>
                       <ext:Grouping ID="Grouping3 runat="server" HideGroupedHeader="true" StartCollapsed="true" />
                  </Features>
               </ext:GridPanel>
            </Component>
      </ext:DropDownField>
1

There are 1 best solutions below

0
Narendra Jadhav On

Cannot read property 'reload' of undefined

In ExtJs docs provide method to get store for combo and store have method to load data. You can refer ExtJs docs

I have create small demo to show you, how it work. Sencha fiddle example

var store = Ext.create('Ext.data.Store', {
    fields: [
        'id','email', 'first', 'last'
    ],
    proxy: {
        type: 'ajax',
        url: 'person.json',
        reader: {
            type: 'json',
            rootProperty: 'data'
        }
    }
});

Ext.create('Ext.form.ComboBox', {
    store: store,
    queryMode: 'local',
    margin:20,
    displayField: 'first',
    valueField: 'id',
    renderTo: Ext.getBody(),
    emptyText:'Select',
    listeners: {
        afterrender: function () {
           this.getStore().load();
        }

    }
});