Ext.net 2.0 ComboBox商店

时间:2012-10-31 15:35:35

标签: asp.net extjs sencha-touch ext.net

我有一个ComboBox控件:

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

在我的代码中,我通过以下方式填充ComboBox商店:

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

但是,在我的javascript中,当我执行comboDatabase.getStore().data.items时,它不返回任何内容。

知道为什么吗?提前谢谢。

2 个答案:

答案 0 :(得分: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>();
}

答案 1 :(得分:-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#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();
    }
}