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

extjs 增删改
Ext.onReady(function() {
	// 开启提示功能
	Ext.QuickTips.init();
    Ext.get("loading").show();

// --------------------------  创建树形面板   ------------------------------------------------
			
	var treepanel = new Ext.tree.TreePanel({
				title : '编码分类导航',
				padding : "10px",
				region : 'west',
				layout : 'fit',
				width : 180,
				split: true,
				collapsible : true, // 允许收缩
				trackMouseOver : true,
				autoScroll : true,
				rootVisible : true,
				tbar : [{
							text : "刷新",
							iconCls : "refresh",
							handler : function() {
								window.location.reload();
							}
						}],
				loader : new Ext.tree.TreeLoader({ // 加载解析树
							autoLoad : true,
							url : "/zzc/zzc/bmzd!list.shtml",
							baseParams:{view_code:""},
							processResponse : function(response, node, callback) {
								var json = Ext.util.JSON.decode(response.responseText);
								try {
									var o = json.bmzds;
									node.beginUpdate();
									var l = this;
									Ext.each(o, function(item) {
											item.text = item.name;
											var n = l.createNode(item);
											if (n) {
												node.appendChild(n);
											}
									    
									});
									node.endUpdate();
									this.runCallback(callback,scope || node,[node]);
								} catch (e) {
									this.handleFailure(response);
								}
							},
							listeners : {
								beforeload : function(l, n, c) {
									
									if (n.attributes.id == "rootNode") {
										l.url = '/zzc/zzc/bmzd!list.shtml';
										l.baseParams = {
											view_code : "",
											needEnabled : false
										}
									} else {
										l.url = '/zzc/zzc/bmzd!list.shtml';
										l.baseParams = {
											view_code : n.attributes.view_code,
											needEnabled : false
										}
									}
									c.call();
								}
							}
						}),
				root : new Ext.tree.AsyncTreeNode({ // 根节点
							text : "编码字典",
							id : 'rootNode',
							expanded : true
						})

			});
		
 // --------------------------------管理面板--------------------------------------------------
  
	// var limit = 20;
    
    // 表单
	var bmzdForm = new Ext.form.FormPanel({
				baseCls : 'x-plain',
				border : false,
				autoScroll : true,
				labelWidth : 80,
				defaultType : "textfield",
				defaults : {
					anchor : '90%',
					msgTarget : 'side'
				},
				padding : "10",
				items : [{
							xtype : "hidden",
							name : "bmzd.id",
							id : "id"
						}, {
							xtype : "hidden",
							name : "bmzd.enabled",
							id : "enabledhidden"
						}, {
							xtype : "hidden",
							name : "bmzd.parent",
							id : "parent"
						}, {
							allowBlank : false,
							fieldLabel : "名称",
							name : "bmzd.name",
							id : "name"
						}, {
							fieldLabel : "简码",
							name : "bmzd.simple_code",
							id : "simple_code"
						}, {
							xtype : "numberfield",
							fieldLabel : "序号",
							name : "bmzd.sort",
							id : "sort"
						}, {
							xtype : "checkbox",
							fieldLabel : "状态",
							boxLabel : "启用",
							id : "enabled",
							listeners : {
								check : function(f, b) {
									Ext.getCmp("enabledhidden").setValue(b);
								}
							}
						}, {
							fieldLabel : "备注",
							name : "bmzd.remark",
							id : "remark"
						}, {
							xtype : "displayfield",
							fieldLabel : "级次码",
							name : "view_code",
							id : "view_code"
						}, {
							xtype : "displayfield",
							fieldLabel : "编码等级",
							name : "lvs",
							id : "lvs"
						}, {
							xtype : "displayfield",
							fieldLabel : "创建时间",
							id : "in_date",
							setValue : function(v) {
								if (this.rendered) {
									if (Ext.isEmpty(v)) {
										this.el.dom.innerHTML = "";
									} else {
										if (Ext.isDate(v)) {
											this.el.dom.innerHTML = v.format("Y-m-d H:i:s");
										} else
											this.el.dom.innerHTML = v;
									}
								} else
									this.value = v;
							}
						}],
						butto