日期:2014-05-16  浏览次数:20415 次

Ext4.2:如果不用store.load会去发送请求吗?
<html>
<head>
<link rel="stylesheet" type="text/css" href="./ExtJS4/resources/css/ext-all.css" />
<script type="text/javascript" src="./ExtJS4/ext-all.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
    var columns = [
        {header:'编号',dataIndex:'id',sortable:true},
        {header:'名称',dataIndex:'name',sortable:true},
        {header:'描述',dataIndex:'descn',sortable:true}
    ];

    var store = new Ext.data.Store({
proxy: {
type: 'ajax',
url: 'data.json',
reader: {
type: 'json',
root: 'root'
}
},
fields: [
            {name: 'id'},
            {name: 'name'},
            {name: 'descn'}
]
    });

    var grid = new Ext.grid.GridPanel({
        renderTo: 'grid',
        store: store,
        columns: columns
    });
    store.load();
});
        </script>
</head>
<body>
<div id="grid"></div>
</body>
</html>

data.json
{root:[
????{id:1,name:'name1',descn:'descn1'},
????{id:2,name:'name2',descn:'descn2'},
????{id:3,name:'name3',descn:'descn3'},
????{id:4,name:'name4',descn:'descn4'},
????{id:5,name:'name5',descn:'descn5'},
????{id:6,name:'name6',descn:'descn6'},
????{id:7,name:'name7',descn:'descn7'},
????{id:8,name:'name8',descn:'descn8'},
????{id:9,name:'name9',descn:'descn9'},
????{id:10,name:'name10',descn:'descn10'}
]}

如果不加store.load();,则数据不会显示,我的疑问是虽然不显示,但是数据是不是已经通过后台获取到了呢,因为我现在希望点击某个按钮后再去请求数据,思路是点击按钮后发送一个Ajax请求,然后执行store.load();,这样就去请求数据并加载了,但是如果已经读到本地了只是没显示,那我就要另想办法了
------解决方案--------------------
测试没发现你的问题啊,4.1,4.2都测试了,去掉load没有发送xhr请求。。


load就是发送请求用的,增加其他非默认配置参数