0

ExtJs 4.0 を使用しています。aspx.cs ページ メソッドにアクセスして、extjs gridpanel のデータを取得したいと考えています。次のコードから解決策を見つけようとしましたが、成功しませんでした。

grid.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
            } ]
        });
    }
});

test.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 に答える