store学习
<script type="text/javascript">
BUI.use(['bui/grid','bui/data'],function(Grid,Data){
var Store = Data.Store,
columns = [
{title : '表头1',dataIndex :'a', width:100},
{id: '123',title : '表头2',dataIndex :'b', width:100},
{title : '表头3',dataIndex : 'c',width:200}
];
var store = new Store({
url : '2a.json',
autoLoad:true
}),
grid = new Grid.Grid({
render:'#grid',
columns : columns,
store : store
});
grid.render();
});
</script>
2a.json数据
{
"result": true,
"rows": [{"a":"123"},{"a":"cdd","b":"edd"},{"a":"1333","c":"eee","d":2}],
"results" : 20
}
在Google浏览器下始终报错
Failed to load resource file:///E:/assets/code/demo.css
Failed to load resource: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. file:///E:/zpj/bui/2a.json?start=0&pageIndex=0&_=1409586123853
XMLHttpRequest cannot load file:///E:/zpj/bui/2a.json?start=0&pageIndex=0&_=1409586123853. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. 2.9grid.html:1
event.returnValue is deprecated. Please use the standard event.preventDefault() instead.
说是浏览器不允许跨域访问具体参见:
http://my.oschina.net/LinBandit/blog/33160
感谢作者的分析。问题完解