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.

4

2 に答える 2

0

ストアを定義するだけです。

<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>();
}
于 2012-11-29T05:11:47.880 に答える
-1

簡単です、ext.net 1.xの同じコード

EXT.NET コード

<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# コード

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();
    }
}
于 2012-11-29T17:52:46.033 に答える