ExtJS 复制对象

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/daichangfu/article/details/84499115

1.Ext.apply 无法复制 Ext.data.JsonStore 等数据源相关的类型

var store2 = new Ext.data.JsonStore({});
var store3={};
Ext.apply(store2,magazine_store); //效果无用.store2仍引用magazine_store,无法独立使用.
Ext.apply(store3,magazine_store); //效果同上.
store3=Ext.apply(store2,magazine_store); //效果同上.

 2.复制JSON对象

var records = []; 
store.each(function(r){ records.push(r.copy()); }); 
var store2 = new Ext.data.Store({ recordType: store.recordType }); 
store2.add(records);

 

展开阅读全文

extjs 缺少对象

11-09

function showRoleDialog() rn var records = grid.getSelectionModel().getSelections();;rn if(records.length == 0) rn Ext.MessageBox.alert('错误', '您还没有选中任何用户!');rn return;rn rn if(records.length >1) rn Ext.MessageBox.alert('错误', '您只能选择一个用户!');rn return;rn rn// var users = new Array();rn// for(var i = 0; i < records.length; i++) rn// users.push(records[i].get('username'));rn// rn var username=records[0].get('username');rn var groupId=records[0].get('groupId');rn if(!userRoleDialog) rn // lazy initialize the dialog and only create it oncern rn userRoleDialog = new function() rn rn var roleType = Ext.data.Record.create([rn name: 'id', type: 'int',rn name: 'rolename', type: 'string',rn name: 'groupId', type: 'int',rn name: 'isdesc', type: 'int',rn name: 'rolecode', type: 'string'rn ]);rn rn var formProxy=new Ext.data.DWRProxy(roleAction.findRolesByGroup,false);rn var roleFromDs = new Ext.data.Store(rn proxy:formProxy,rn reader: new Ext.data.DwrArrayReader(id:'id', roleType)rn );rn var toProxy = new Ext.data.DWRProxy(userRoleAction.findRolesByUser,false);rn var roleToDs = new Ext.data.Store(rn proxy: toProxy,rn reader: new Ext.data.DwrArrayReader(id:'id', roleType)rn ); rn rn// var username; //当前编辑的用户帐号rn var dataReadyFlag = false; //数据加载完成标记,确保dwr已执行完毕rn rn toProxy.on('loaded', refreshAfterLoad); rnrn var itemSelector = new Ext.form.FormPanel( rn hideLabels: true,rn width:480,rn bodyStyle:'padding:5px 5px 0',rn items:[rn xtype:'itemselector',rn name:'roleSelector',rn //fieldLabel:'权限设置',rn fromStore: roleFromDs,rn toStore: roleToDs,rn valueField: 'rolecode',rn displayField: 'rolename',rn msWidth:220,rn msHeight:260,rn imagePath: '../../js/ext/resources/images',rn toLegend:'已授予',rn fromLegend:'可用'rn ]rn );rn rn var dialog = new Ext.Window( rn layout: 'fit',rn pageX: 0,rn pageY: 0,rn width:490,rn height:350,rn resizable: false,rn title: '角色设置',rn //border:false,rn closeAction:'hide',rn plain:true,rn modal: true,rn items: [itemSelector],rn buttons: [rn text:'保存',rn handler: doSetupRolern ,rn text: '取消',rn handler: function() rn dialog.hide();rn rn ] rn );rn rn //数据加载完毕事件,用于刷新控制标记rn function refreshAfterLoad() rn //itemSelector.valueChanged(authorityToDs);rn dataReadyFlag = true;rn rn rn //保存权限设置rn function doSetupRole() rn if(dataReadyFlag == false) rn Ext.MessageBox.alert('错误', '初始数据尚未加载完毕,请稍候!');rn return;rn rn var values = [];rn var v = Ext.util.Format.trim(itemSelector.getForm().findField('roleSelector').getValue());rn if(v.length > 0) rn values = values.concat(v.split(','));rn rn userRoleAction.resetUserRoles(username, values, doSetupRoleResp);rn rn function doSetupRoleResp(ret) rn Ext.MessageBox.alert('OK', '操作成功');rn dialog.hide();rn rn rn rn this.load = function(username,groupId) rn alert(username+"000000000"+groupId);rn dataReadyFlag = false;rn roleFromDs.removeAll();rn roleToDs.removeAll();rn roleFromDs.load(params:args:[groupId]);rn roleToDs.load(params:args:[username]);rn // username = username; rn rn rn this.show = function() rn dialog.show();rn rn ();rn rn userRoleDialog.load(username,groupId); rn userRoleDialog.show();rn rnrn我的这段代码老报缺少对象啊 论坛

没有更多推荐了,返回首页