Ext.grid.RowExpander的应用2

     前两天用到extjs中的插件Ext.grid.RowExpander,但是我的代码都是继承vifir网站中提供的EasyJF.Ext.CrudPanel,这个累提供的常用的增删改查的操作,我们这里写入我们相关的表单信息就可以,如:
EasyJF.Ext.CrudPanel的代码:

EasyJF.Ext.CrudPanel=Ext.extend(Ext.Panel,{
	closable: true,   //关闭
  	autoScroll:true,  //自动显示工具条
  	layout:"fit",     //
  	gridViewConfig:{},   
  	linkRenderer:function(v)
  	{
  		if(!v)return "";
  		else return String.format("{0}",v);
  	},
    search:function()
    {   
    	this.refresh(); 
    },
    refresh:function()
    {
    	this.store.removeAll();
   		this.store.reload();
    },    
    initWin:function(width,height,title)
    {
    	var win=new Ext.Window({
			width:width,
			height:height,
			buttonAlign:"center",
			title:title,
			modal:true,
			shadow:true,
			closeAction:"hide",
			items:[this.fp],
			buttons:[{text:"保存",
					  handler:this.save,
					  scope:this},
					  {text:"清空",
					   handler:this.reset,
					   scope:this},
					  {text:"取消",
					   handler:this.closeWin,
					   scope:this}
					   	]					  
		});
		return win;
    },
    showWin:function()
	{	
		if(!this.win){
			if(!this.fp){
				this.fp=this.createForm();
			}
		this.win=this.createWin();
		this.win.on("close",function(){this.win=null;this.fp=null;},this);
		}
		this.win.show();
	},
	create:function()
	{
		this.showWin();
		this.reset();
	},
	save:function()
	{
		var id=this.fp.form.findField("id").getValue();		
		this.fp.form.submit({
				waitMsg:'正在保存。。。',
	            url:this.baseUrl+"?cmd="+(id?"update":"save"),
	            method:'POST',
	            success:function(){
	           	this.closeWin();
	           	this.store.reload();          	
	            },
	            scope:this
		});	
	},
	reset:function()
	{
	if(this.win)this.fp.form.reset();
	},
	closeWin:function()
	{
		if(this.win)this.win.close();
		this.win=null;
		this.fp=null;
	},
	edit:function()
	{
		var record=this.grid.getSelectionModel().getSelected();
		if(!record){
			Ext.Msg.alert("提示","请先选择要编辑的行!");
			return;
		}
	    var id=record.get("id");
	    this.showWin();
	    this.fp.form.loadRecord(record); 
	},	
	removeData:function()
	{
			var record=this.grid.getSelectionModel().getSelected();
			if(!record){
				Ext.Msg.alert("提示","请先选择要编辑的行!");
				return;
			}
			var m=Ext.MessageBox.confirm("删除提示","是否真的要删除数据?",function(ret){
			if(ret=="yes"){
			  Ext.Ajax.request({
	            url:this.baseUrl+'?cmd=remove',
	            params:{
	                'id':record.get("id")
	            },
	            method:'POST',
	            success:function(response){
	            var r=Ext.decode(response.responseText);
	            if(!r.success)Ext.Msg.alert("提示信息","数据删除失败,由以下原因所致:
"+(r.errors.msg?r.errors.msg:"未知原因")); else{ Ext.Msg.alert("提示信息","成功删除数据!",function(){ this.store.reload(); },this); } }, scope:this }); }},this); }, initComponent : function(){ this.store=new Ext.data.JsonStore({ id:"id", url: this.baseUrl+'?cmd=list', root:"result", totalProperty:"rowCount", remoteSort:true, fields:this.storeMapping}); this.store.paramNames.sort="orderBy"; this.store.paramNames.dir="orderType"; this.cm.defaultSortable=true; EasyJF.Ext.CrudPanel.superclass.initComponent.call(this); var viewConfig=Ext.apply({forceFit:true},this.gridViewConfig); this.grid=new Ext.grid.GridPanel({ store: this.store, cm: this.cm, trackMouseOver:false, loadMask: true, viewConfig:viewConfig, tbar: [' ', { text: '添加', pressed: true, handler: this.create, scope:this },' ', { text: '修改', pressed: true, handler: this.edit, scope:this },' ', { text: '删除', pressed: true, handler: this.removeData, scope:this },' ', { text: '刷新', pressed: true, handler: this.refresh, scope:this } ,new Ext.Toolbar.Fill(), 'Search: ', { xtype:"textfield", width:100, pressed: true, scope:this }, { text: '查询', pressed: true, handler: this.search, scope:this },' ' ], bbar: new Ext.PagingToolbar({ pageSize: 10, store: this.store, displayInfo: true, displayMsg: 'Displaying topics {0} - {1} of {2}', emptyMsg: "No topics to display" }) }); this.grid.on("celldblclick",this.edit,this); this.add(this.grid); this.store.load(); } })

如果我们想做个增删改查的操作,例如我们在项目中常用到的友情链接,下面的代码就是这样写了:

LinkPanel=Ext.extend(EasyJF.Ext.CrudPanel,{
	id:"linkPanel",
	title:"友情链接管理",
	baseUrl:"link.ejf",
	createForm:function(){
	var formPanel=new Ext.form.FormPanel({
		frame:true,
		labelWidth:50,
		labelAlign:'right',
		defaults:{width:340,xtype:"textfield"},
		items:[{xtype:"hidden",name:"id"},
			{fieldLabel:'标题',name:'title'},
			{fieldLabel:'URL',name:'url'},
			{fieldLabel:'RSS',name:'rss'},
			{xtype:"textarea",fieldLabel:'简介',name:'intro'}
            ]
	});
	return formPanel;
    },
    createWin:function()
    {
    	return this.initWin(438,220,"友情链接管理");
    },
    storeMapping:["id","title","url","rss","intro"],   
	initComponent : function(){
		this.cm=new Ext.grid.ColumnModel([
		{header: "标题", sortable:true,width: 300, dataIndex:"title"},
		{header: "URL", sortable:true,width: 300, dataIndex:"url",renderer:this.linkRenderer},
		{header: "RSS", sortable:true,width: 300, dataIndex:"rss",renderer:this.linkRenderer},
		{header: "简介", sortable:true,width: 300, dataIndex:"intro"}
        ])
       LinkPanel.superclass.initComponent.call(this); 	
	}	
});

呵呵。就这么简单了!我们的一个友情连接的管理就实现了。

如果我们做一个这样的功能:

 

我们需要用到Ext.grid.RowExpander,这个时候我们看到Ext.grid.RowExpander是需要放在Ext.grid.GridPanel下面的plugins
中,但是我使用了继承EasyJF.Ext.CrudPanel,在子类中我们没有办法把plugins赋值给CrudPanel,这时候我们需要重新来构造父类,在父类中定义一个属性在子类里面实现,如我们在父类中plugins:this.expander,那么我们在子类中就需要定

expander: new Ext.grid.RowExpander({
            tpl : new Ext.Template(
            '

标题: {title}


', '

简介: {content}

' ) }),

这样就可以实现以上的功能了,我们在

 

 

tpl : new Ext.Template(
            '

标题: {title}


', '

简介: {content}

'

中可以定义自己的样式来显示我们内容。

 

 

http://www.easyjf.com/blog/html/20080630/1671168.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
辽B代驾管理系统对代驾订单管理、用户咨询管理、代驾订单评价管理、代驾订单投诉管理、字典管理、论坛管理、公告管理、新闻信息管理、司机管理、用户管理、管理员管理等进行集中化处理。经过前面自己查阅的网络知识,加上自己在学校课堂上学习的知识,决定开发系统选择小程序模式这种高效率的模式完成系统功能开发。这种模式让操作员基于浏览器的方式进行网站访问,采用的主流的Java语言这种面向对象的语言进行辽B代驾管理系统程序的开发,在数据库的选择上面,选择功能强大的Mysql数据库进行数据的存放操作。辽B代驾管理系统的开发让用户查看代驾订单信息变得容易,让管理员高效管理代驾订单信息。 辽B代驾管理系统具有管理员角色,用户角色,这几个操作权限。 辽B代驾管理系统针对管理员设置的功能有:添加并管理各种类型信息,管理用户账户信息,管理代驾订单信息,管理公告信息等内容。 辽B代驾管理系统针对用户设置的功能有:查看并修改个人信息,查看代驾订单信息,查看公告信息等内容。 辽B代驾管理系统针对管理员设置的功能有:添加并管理各种类型信息,管理用户账户信息,管理代驾订单信息,管理公告信息等内容。 辽B代驾管理系统针对用户设置的功能有:查看并修改个人信息,查看代驾订单信息,查看公告信息等内容。 系统登录功能是程序必不可少的功能,在登录页面必填的数据有两项,一项就是账号,另一项数据就是密码,当管理员正确填写并提交这二者数据之后,管理员就可以进入系统后台功能操作区。项目管理页面提供的功能操作有:查看代驾订单,删除代驾订单操作,新增代驾订单操作,修改代驾订单操作。公告信息管理页面提供的功能操作有:新增公告,修改公告,删除公告操作。公告类型管理页面显示所有公告类型,在此页面既可以让管理员添加新的公告信息类型,也能对已有的公告类型信息执行编辑更新,失效的公告类型信息也能让管理员快速删除。新闻管理页面,此页面提供给管理员的功能有:新增新闻,修改新闻,删除新闻。新闻类型管理页面,此页面提供给管理员的功能有:新增新闻类型,修改新闻类型,删除新闻类型。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值