0

我正在使用 ExtJs 4.0。我想访问 aspx.cs 页面方法来获取 extjs 网格面板中的数据。我试图从以下代码中找到解决方案,但没有成功。

网格.js

Ext.application({
    launch: function() {
        // Model definition and remote store (used Ext examples data)
        Ext.define('ForumThread', {
            extend: 'Ext.data.Model',
            fields: ['countryId', 'countryName'],
            idProperty: 'countryId'
        });

         var store = Ext.create('Ext.data.Store', {
        pageSize: 20,
        model: 'ForumThread',
        autoLoad: true,
        proxy: {
            type: 'ajax',
            url: 'mindbody.reports/test.aspx/display',
            reader: {                
                type: 'json',
                method: "GET",
                totalProperty: 'totalCount'
            }
        }
    });

        // Define grid that will automatically restore its selection after store reload
        Ext.define('PersistantSelectionGridPanel', {
            extend: 'Ext.grid.Panel',

        });

        // Create instance of previously defined persistant selection grid panel
        var grid = Ext.create('PersistantSelectionGridPanel', {
            autoscroll: true,
            height: 300,
            renderTo: Ext.getBody(),
            //region: 'center',
            store: store,
            multiSelect: true, // Delete this if you only need single row selection
            stateful: true,
            forceFit: true,
            loadMask: false,
            viewConfig: {
                stripeRows: true
            },
            columns:[{
                id: 'countryId',
                text: "countryId",
                dataIndex: 'countryId',
                flex: 1,
                sortable: false
            },{
                text: "countryName",
                dataIndex: 'countryName',
                width: 70,
                align: 'right',
                sortable: true
            } ]
        });
    }
});

测试.aspx.cs

public string display()
{
      country obj = new country();
      JavaScriptSerializer serializer = new JavaScriptSerializer();
      return serializer.Serialize(obj.SelectAll());  
}

url: 'mindbody.reports/test.aspx/display'我正在尝试从 test.aspx 页面的显示方法中获取数据,但没有得到任何数据,甚至没有错误。我在调用方法中有任何问题。

4

1 回答 1

2

在 test.aspx.cs 页面上的方法 display() 之前添加以下代码行

  [System.Web.Services.WebMethod()]
于 2012-10-10T08:08:28.953 回答