在 GridPanel 存储中访问 ASPX.cs 页面的方法,以便在 extJS 中获取数据



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

网格.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());  
}

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

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

  [System.Web.Services.WebMethod()]

最新更新