0

I have a ComboBox Control:

<ext:ComboBox id="comboDatabase"></ext:ComboBox>

In my code I populate the ComboBox Store by:

comboDatabase.Store.Primary.DataSource = dbList
comboDatabase.Store.Primary.DataBind()

However, in my javascript, when I do comboDatabase.getStore().data.items, it returns nothing.

Any idea why? Thanks in advance.

slee
  • 344
  • 3
  • 5
  • 15
  • 1
    I don't think a Store is automatically created by getting .Store.Primary. You might need to create a Store first and add to the ComboBox. Posting a full .aspx code sample demonstrating how to reproduce the issue may be required. – geoffrey.mcgill Oct 31 '12 at 16:06

2 Answers2

0

Just define the store:

<ext:ComboBox ID="PACKING" runat="server" FieldLabel="PACKING" 
           ValueField="id" DisplayField="pk" QueryMode="Local">
  <Store>
    <ext:Store ID="PackingStore" runat="server" Data='<%# packings %>'>
      <Model>
        <ext:Model runat="server">
          <Fields>
            <ext:ModelField Name="id" />
            <ext:ModelField Name="pk" />
          </Fields>
        </ext:Model>
      </Model>
      <Reader>
        <ext:ArrayReader IDProperty="id" />
      </Reader>
    </ext:Store>
  </Store>
</ext:ComboBox>

c#:

protected object packings
{
  get { return ctx.Packings.Select(p => new object[] { p.id, p.PackingName }).ToArray<object>();
}
Boris Gappov
  • 2,483
  • 18
  • 23
-1

Is Easy, the same code of ext.net 1.x

EXT.NET CODE

<ext:Store ID="Store1" runat="server" >                        
    <Model>
        <ext:Model runat="server" IDProperty="code">
        <Fields>
            <ext:ModelField Name="code_item" />
            <ext:ModelField Name="description_item" />
        </Fields>                                
        </ext:Model>
    </Model>                                               
</ext:Store>

...

<ext:combobox id="combo" runat="server" storeid="Store1" displayfield="description_item" valuefield="code_item" />

C# CODE

private void LoadStore(Store store, string query)
{
        OdbcConnection Odbc = new OdbcConnection();
    try
    {
        Odbc.ConnectionString = mntClass.HelperDB.strConn(); //mntClass is my particular dll
        Odbc.Open();
        DataSet objDataset1 = new DataSet();
        objDataset1 = mntClass.HelperDB.ExecuteSelectQuery(Odbc, query);
        store.DataSource = objDataset1;
        store.DataBind();   
    }
    catch (OdbcException)
    {

    }
    finally
    {
      Odbc.Close();
    }
}
cmujica
  • 1,304
  • 1
  • 18
  • 27