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

Is Easy,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 回答