Ext好难学啊,手册也不大方便看~~只好提问了。
首先,我在app/model文件下建了Bugs.js
Ext.define('TutorialApp.model.Bugs', {
    extend: 'TutorialApp.model.Base',    fields: [
        {name:'id', type:'int'},
        {name:'importanceZh', type:'string'},
        {name:'versionNumber', type:'string'},
        {name:'title', type:'string'},
        {name:'statusZh', type:'string'},
        {name:'creatorNickName', type:'string'},
        {name:'gmtCreated', type:'string'},
        {name:'handlerNickName', type:'string'}
    ]
});然后在app/store文件下建了Bugs.js
Ext.define('TutorialApp.store.Bugs', {
    extend: 'Ext.data.Store',
    alias: 'store.bugs',
    model: 'TutorialApp.model.Bugs',
    autoLoad:true,
    pageSize: 30,
    proxy: {
        type:"jsonp",
        url : "http://localhost:8081/api/testing/page_bugs",
        reader:{
            type:"json",
            rootProperty:"data.data",
            totalProperty: 'data.totalRows',
            messageProperty: "msg"
        }
    }
});
由于我的请求跨域了,所以type要用jsonp,声明,我对jsonp不了解,只是在网上查到跨域请求得写jsonp而不是ajax。然后在classic/src/view/main文件下建了BugList.js:
Ext.define('TutorialApp.view.main.BugList', {
    extend: 'Ext.grid.Panel',
    xtype: 'buglist',    requires: [
        'TutorialApp.store.Bugs'
    ],    title: '缺陷列表',    store: {
        type: 'bugs'
    },    columns: [
      { text: 'ID',  dataIndex: 'id' },
      { text: '重要度', dataIndex: 'importanceZh', flex: 1 },
      { text: '版本', dataIndex: 'versionNumber', flex: 1 },
      { text: '标题', dataIndex: 'title', flex: 1 },
      { text: '状态', dataIndex: 'statusZh', flex: 1 },
      { text: '创建人', dataIndex: 'creatorNickName', flex: 1 },
      { text: '创建日期', dataIndex: 'gmtCreated', flex: 1 },
      { text: '处理人', dataIndex: 'handlerNickName', flex: 1 }
    ],    listeners: {
        // select: 'onItemSelected'
    }
});
现在问题来了。我发现请求里ext自己补了一串分页参数以及一个回调:
http://localhost:8081/api/testing/page_bugs?_dc=1501641196586&page=1&start=0&limit=25&callback=Ext.data.JsonP.callback1
这回调需要我做什么吗?
数据返回了,但是也报错了:
Uncaught SyntaxError: Unexpected token :
我该怎么才能正确解析数据?还有,如果我想传的参数是rowsPerPage=10&currentPage=1而不是page=1&start=0&limit=25该怎么做?