1

我正在使用 ExtJs 4.1。我想在 extjs 中开发基本的网格面板应用程序,它通过 WebService 显示来自 linq 的数据我没有使用 asp.net MVC。那我怎么显示??

我试图从以下代码中找到解决方案,但没有成功。

网格.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: '../reports/test.asmx/display',
            dataType: "json",
            contentType: "application/json; charset=utf-8",
             //url: '/grid.json',
            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
            } ]
        });
    }
});

测试.asmx

[WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json , UseHttpGet = true, XmlSerializeString = false)]
    public string display()
    {
        country obj = new country();
        //return obj.SelectAll();
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        return serializer.Serialize(obj.SelectAll());
    }

但我在萤火虫中遇到以下错误 在此处输入图像描述

4

0 回答 0