GridPanel商店未加载

时间:2013-09-23 19:00:24

标签: json web-services extjs store ext.net

我正在尝试加载一个简单的GridPanel,其中包含在代码后面创建的商店。我不确定我缺少什么但是当我将Store添加到GridPanel时它只是说“正在加载......”并且从不加载。

GridPanel的定义如下:

<ext:GridPanel ID="SearchSoftwareGrid" runat="server" MultiSelect="true" Height="224"
    Padding="1" Width="398">
    <ColumnModel>
        <Columns>
            <ext:Column ID="Column4" runat="server" Text="Publisher" Width="45" DataIndex="PUBLISHER"
                Flex="1" />
            <ext:Column ID="Column5" runat="server" Text="Product" Width="175" DataIndex="PRODUCT" />
            <ext:Column ID="Column6" runat="server" Text="Version" Width="50" DataIndex="PRODUCT_VERSION" />
            <ext:Column ID="Column7" runat="server" Text="Instance Count" Width="85" DataIndex="INSTANCE_COUNT" />
        </Columns>
    </ColumnModel>
    <View>
        <ext:GridView ID="GridView2" runat="server">
            <Plugins>
                <ext:GridDragDrop ID="GridDragDrop2" runat="server" DragGroup="secondGridDDGroup"
                    DropGroup="firstGridDDGroup" />
            </Plugins>
            <Listeners>
                <Refresh Handler="#{SearchSoftwareGrid}.body.unmask(); #{btnSearchSoftware}.enable();"
                    Delay="1" />
            </Listeners>
        </ext:GridView>
    </View>
</ext:GridPanel>

这是我用来在代码后面创建Store的方法:

private Ext.Net.Store GetSoftwareStore(string search)
{
string proxyUrl = softwareUrl + search;

Ext.Net.Model softwareStoreModel = new Ext.Net.Model();
softwareStoreModel.Fields.Add(new Ext.Net.ModelField("PUBLISHER", ModelFieldType.String));
softwareStoreModel.Fields.Add(new Ext.Net.ModelField("PRODUCT", ModelFieldType.String));
softwareStoreModel.Fields.Add(new Ext.Net.ModelField("PRODUCT_VERSION", ModelFieldType.String));
softwareStoreModel.Fields.Add(new Ext.Net.ModelField("INSTANCE_COUNT", ModelFieldType.String)); 

Ext.Net.Store resultStore = new Ext.Net.Store()
{
    AutoLoad = true,
    Proxy =
    {
        new Ext.Net.AjaxProxy()
        {
            Json = true,
            ActionMethods = { Read = Ext.Net.HttpMethod.POST, Create = Ext.Net.HttpMethod.POST },
            Url = proxyUrl,
            Headers = {
                new Ext.Net.Parameter("Accept", "application/json"),
                new Ext.Net.Parameter("Content-Type", "application/json")
            },
            Reader = { new Ext.Net.JsonReader() { Root = "" } },
            Writer = { new Ext.Net.JsonWriter() { Root = "", Encode = true } }
        }
    }
};
resultStore.Model.Add(softwareStoreModel);        

return resultStore;
}

我尝试像这样添加商店,用户输入txtSearchsoftware并用于填充上面的proxyUrl

SearchSoftwareGrid.Store.Add(GetSoftwareStore(txtSearchsoftware.Text));

proxyUrl用于返回一些JSON的Web服务。例如:

  

的http:// [计算机] / OperationalControlServices /服务1 /数据/ ComponentMapping搜索= DB2

我知道Web服务很好,因为它使用Fiddler正确返回。 提前谢谢!

1 个答案:

答案 0 :(得分:0)

尝试

SearchSoftwareGrid.Store= GetSoftwareStore(txtSearchsoftware.Text);