请问我通过在做extjs时用json后台获取了一个数据,用store.on函数得到赋值给变量,但是怎么在函数外面得到

学习 时间:2026-03-30 08:58:52 阅读:7072
请问我通过在做extjs时用json后台获取了一个数据,用store.on函数得到赋值给变量,但是怎么在函数外面得到store.on('load',function(){animals = store.getAt(0).get('animals');alert(aa);}) ;store.load();怎么得到animals的值在函数外面?先谢谢大哥哥大姐姐了.还有能写个例子最好.设置个全局变量行吗?能举个例子吗?我对这个callback不怎么熟悉.我试了一下还是不行,能举个例子吗?可能是我的理解错误.呵呵

最佳回答

愉快的百合

悦耳的溪流

2026-03-30 08:58:52

1 var ds = new Ext。data。Store({2 proxy: new Ext。data。ScriptTagProxy({3 url: 'yoururl。json'4 }),5 reader: new Ext。data。JsonReader({6 root: 'Fields',7 totalProperty: 'totalCount',8 id: 'id'9 }, [10 ,11 12 ])13 });14 var combobox = new Ext。form。ComboBox({15 id:'combobox',16 x:0,17 y:20,18 store: da,19 displayField:'field',20 typeAhead: false,21 loadingText: '正在加载字段。。。',22 forceSelection: false,23 triggerAction: 'all',24 hideTrigger:false,25 minChars:1,26 anchor: '100%',27 pageSize:1028 });json输出注意stcCallback1007要用程序输出请求过来的参数callback的值stcCallback1007(,]});stcCallback1007(,]});stcCallback1007(,]});不好意思,看错了,以下是grid的 // create the Data Store var singleTablestore = new Ext。data。JsonStore({ root: 'topics', totalProperty: 'totalCount', idProperty: 'tableid', remoteSort: true, fields: [ ,'name','description','importdate' ], // load using script tags for cross domain, if the data in on the same domain as proxy: new Ext。data。ScriptTagProxy({ url: 'abc。json' }) }); singleTablestore。setDefaultSort('date', 'desc'); var singleTable = new Ext。grid。EditorGridPanel({ id:'singleTable-panel', layout:'anchor', anchor:['100%','100%'], title:'单表数据处理', store: singleTablestore, //trackMouseOver:false, //disableSelection:true, loadMask: true, autoScroll:true, // grid columns columns:[{ id: 'name', header: "数据表名称", dataIndex: 'name', width: 200, sortable: true, renderer:renderTips },{ id: 'description', // id assigned so we can apply custom css (e。g。 。x-grid-col-topic b ) header: "数据表描述", dataIndex: 'description', renderer:renderTips2, editor:new Ext。form。TextField(), width: 270, // renderer: renderTopic, sortable: true },{ header: "导入日期", dataIndex: 'importdate', width: 150, sortable: true },{ id: 'tableid', header: "操作", dataIndex: 'tableid', width: 450, resizable: false, //editor:new Ext。Button() renderer: renderLast //items:[new Ext。Button()] }], // customize view config viewConfig: { //forceFit:true, enableRowBody:true, //showPreview:true }, // paging bar on the bottom bbar: new Ext。PagingToolbar({ pageSize: 20, store: singleTablestore, displayInfo: true, displayMsg: '当前显示 - 条,共 条', beforePageText:'第', afterPageText:'页,共页', emptyMsg: "没有相应内容", items:[ '-', { pressed: true, enableToggle:true, text: 'Show Preview', cls: 'x-btn-text-icon details', toggleHandler: function(btn, pressed){ 。。。 } }] }) }); singleTable。on('afteredit', afterEdit, this ); singleTable。on('show', function()});}, this ); function afterEdit(e) { 。。。 }abc。jsonstcCallback1009(,]});

最新回答共有2条回答

  • 鲤鱼世界
    回复
    2026-03-30 08:58:52

    1 var ds = new Ext。data。Store({2 proxy: new Ext。data。ScriptTagProxy({3 url: 'yoururl。json'4 }),5 reader: new Ext。data。JsonReader({6 root: 'Fields',7 totalProperty: 'totalCount',8 id: 'id'9 }, [10 ,11 12 ])13 });14 var combobox = new Ext。form。ComboBox({15 id:'combobox',16 x:0,17 y:20,18 store: da,19 displayField:'field',20 typeAhead: false,21 loadingText: '正在加载字段。。。',22 forceSelection: false,23 triggerAction: 'all',24 hideTrigger:false,25 minChars:1,26 anchor: '100%',27 pageSize:1028 });json输出注意stcCallback1007要用程序输出请求过来的参数callback的值stcCallback1007(,]});stcCallback1007(,]});stcCallback1007(,]});不好意思,看错了,以下是grid的 // create the Data Store var singleTablestore = new Ext。data。JsonStore({ root: 'topics', totalProperty: 'totalCount', idProperty: 'tableid', remoteSort: true, fields: [ ,'name','description','importdate' ], // load using script tags for cross domain, if the data in on the same domain as proxy: new Ext。data。ScriptTagProxy({ url: 'abc。json' }) }); singleTablestore。setDefaultSort('date', 'desc'); var singleTable = new Ext。grid。EditorGridPanel({ id:'singleTable-panel', layout:'anchor', anchor:['100%','100%'], title:'单表数据处理', store: singleTablestore, //trackMouseOver:false, //disableSelection:true, loadMask: true, autoScroll:true, // grid columns columns:[{ id: 'name', header: "数据表名称", dataIndex: 'name', width: 200, sortable: true, renderer:renderTips },{ id: 'description', // id assigned so we can apply custom css (e。g。 。x-grid-col-topic b ) header: "数据表描述", dataIndex: 'description', renderer:renderTips2, editor:new Ext。form。TextField(), width: 270, // renderer: renderTopic, sortable: true },{ header: "导入日期", dataIndex: 'importdate', width: 150, sortable: true },{ id: 'tableid', header: "操作", dataIndex: 'tableid', width: 450, resizable: false, //editor:new Ext。Button() renderer: renderLast //items:[new Ext。Button()] }], // customize view config viewConfig: { //forceFit:true, enableRowBody:true, //showPreview:true }, // paging bar on the bottom bbar: new Ext。PagingToolbar({ pageSize: 20, store: singleTablestore, displayInfo: true, displayMsg: '当前显示 - 条,共 条', beforePageText:'第', afterPageText:'页,共页', emptyMsg: "没有相应内容", items:[ '-', { pressed: true, enableToggle:true, text: 'Show Preview', cls: 'x-btn-text-icon details', toggleHandler: function(btn, pressed){ 。。。 } }] }) }); singleTable。on('afteredit', afterEdit, this ); singleTable。on('show', function()});}, this ); function afterEdit(e) { 。。。 }abc。jsonstcCallback1009(,]});

上一篇 《儒林外史》范进中举后能当什么官

下一篇 北回归线和北极圈之间的地区是?