博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
extjs4.1 grid 分组 (对象是一个object)以及其它。
阅读量:6704 次
发布时间:2019-06-25

本文共 12336 字,大约阅读时间需要 41 分钟。

hot3.png

前几天做分组,老是遇到问题,后来经过测试,找到了解决方法。

model中:

Ext.define('Sharera.model.community.Topic', {    extend: 'Ext.data.Model',    idProperty: 'id',    fields: [		        {name:'id',type:'long'},			{name:'title',type:'string'},		        {name:'community.name',type:'string'},         {name:'community.id',type:'long'},		        {name:'community',type:'object'},			{name:'creator',type:'object'},			{name:'participator',type:'object'},			{name:'created',type:'string'},			{name:'modified',type:'string'},			{name:'enabled',type:'boolean'}    ]});
store:

/** * The com.sharera.web.Topic store definition */Ext.define('Sharera.store.community.Topic', {    extend: 'Ext.data.Store',    autoLoad: false,    autoSync: false,    fields: ['id','title','community','creator','participator','created','modified','enabled'],    baseUrl : context+'api/topic',    sorters: {property: 'created', direction: 'DESC'},    groupField: 'community.name',      proxy: {        type: 'rest',        url: context+'api/topic',        model: 'Sharera.model.community.Topic',		reader : {			type : 'json'		},		writer : {			type : 'json'		},		listeners : {			exception : function(proxy, response, operation) {				if (operation) {					Ext.Sharera.error("错误",operation.error.statusText);									} else {					// May be a proxy error...				}			},			load:function(store,records,successFull,o){        		store.sort([{property : 'community',direction: 'ASC'}]);        }		}    },    setUrlforForm : function(id) {    	if(id==undefined || id==null)    		this.proxy.url = this.baseUrl;    	else    		this.proxy.url = this.baseUrl + "/" + id + ".json";	},	setUrlforQuery : function(name) {		if (name == null)			name = 'list';		this.proxy.url = this.baseUrl + "/" + name + ".json";	},	setUrlforQuery4Ext : function(name) {		if (name == null)			name = 'listext';		this.proxy.url = this.baseUrl + "/" + name + ".json";	}});

grid中的代码:

//插件添加     features: [{        ftype: 'groupingsummary',        groupHeaderTpl: '{[values.rows[0].data.community.name]} (共:{rows.length}个话题)',        hideGroupedHeader: true,        enableGroupingMenu: false     }],
header:'操作',               align: 'center',               xtype:'actioncolumn',                              width:70,               items: [{            	   iconCls : 'icon-checkin-action',                   tooltip: '查看',                   handler: function(grid, rowIndex, colIndex, item) {                   	                       var rec = grid.getStore().getAt(rowIndex);					  var formWin= Ext.create("Sharera.view.community.Topic.FormDisplay",{bid:rec.data.id});				      var formObj=formWin.down('form').getForm();				      var panel=formWin.down('panel[ref=discussion]'); 					  var fstore = Ext.create("Sharera.store.community.Topicform");                					      			                      	  fstore.setUrlforForm(rec.data.id);                	  fstore.load(                			{                        	    scope: this,                        	    callback: function(records, operation, success) {                        	    	formObj.loadRecord(records[0]);                        	    	var parValue=new Array();                        	    	var participators=records[0].data.participator;                        	        var isUse;                        	        if(records[0].data.enabled){                        	        	isUse='是';                        	        }                        	        if(!records[0].data.enabled){                        	            isUse='否';                        	                                	        }                        	    	for(var i=0;i
  '+discussions[i].content+'

  ' +discussions[i].creator.fullname+'  '+discussions[i].created }); container.add({ xtype:'container', width:'100%', padding:'5', layout: { type: 'hbox', pack: 'end' , align: 'stretchmax' }, items:[{ xtype:'button', text:'禁用', ref:'forbidden', check:false, handler: function(b) { Ext.MessageBox.confirm('请确认', '您确认要禁用该讨论吗?',function(btn){ if(btn=='yes'){ Ext.Ajax.request({ headers: {"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}, url:context+'api/discussion/check/'+id+'.json', method:'put', success:function(response, opts){ b.hide(); var useButton=b.ownerCt.down('button[ref=use]'); useButton.show(); useButton.check=true; if(b.check){ useButton.setText('禁用(已阅)'); }else{ checkLength++; } panel.setTitle('讨论管理:(共有'+discussions.length+'条讨论,显示'+discussions.length+'条,已阅'+checkLength+'条)'); panel.removeBodyCls() panel.addBodyCls('background:#196666'); Ext.Sharera.msg("成功",'讨论删除成功'); }, failure:function(response, opts){ Ext.Sharera.error("错误",'讨论删除失败'); } }); } }); } },{ xtype:'button', text:'已禁用', ref:'use', check:false, iconCls : 'icon-cancel-action', handler: function(b) { Ext.MessageBox.confirm('请确认', '您确认要启用该讨论吗?',function(btn){ if(btn=='yes'){ Ext.Ajax.request({ headers: {"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}, url:context+'api/discussion/check/'+id+'.json?type=setusable', method:'put', success:function(response, opts){ b.hide(); var fb=b.ownerCt.down('button[ref=forbidden]'); fb.show(); fb.check=true; fb.setText('禁用(已阅)'); Ext.Sharera.msg("成功",'讨论启用成功'); }, failure:function(response, opts){ Ext.Sharera.error("错误",'讨论启用失败'); } }); } }); }, listeners:{ mouseover:function(view){ view.setIconCls('icon-tick'); view.setText('启用'); }, mouseout:function(view){ if(view.check){ view.setIconCls('icon-cancel-action'); view.setText('已禁用'); } } } }], listeners:{ render: function(view){ var self=view; var useButton=view.down('button[ref=use]'); useButton.hide(); } } }); containers.push(container); } panel.add(containers); }, failure:function(response, opts){ Ext.Sharera.error("错误",'话题禁用修改失败'+message); } }); } } ); } },{ iconCls : 'icon-cancel-action', tooltip: '禁用该话题', handler: function(grid, rowIndex, colIndex, item) { var id=grid.getStore().getAt(rowIndex).data.id; var store=grid.getStore(); Ext.MessageBox.confirm('请确认', '您确认要禁用该话题吗?',function(btn){ if(btn=='yes'){ Ext.Ajax.request({ url:context+'api/topic/check/'+id, method:'put', success:function(response, opts){ Ext.Sharera.msg("成功",'话题禁用成功'); store.load(); }, failure:function(response, opts){ Ext.Sharera.error("错误",'话题禁用修改失败'+message); } }); } }); }, getClass:function(v,o,r,rowIndex,colIndex,store){ if(r.data.enabled){ return 'icon-cancel-action'; } return 'x-hidden' } },{ iconCls : 'icon-coins-action', tooltip: '启用该话题', handler: function(grid, rowIndex, colIndex, item) { var id=grid.getStore().getAt(rowIndex).data.id; var store=grid.getStore(); Ext.MessageBox.confirm('请确认', '您确认要启用该话题吗?',function(btn){ if(btn=='yes'){ Ext.Ajax.request({ url:context+'api/topic/check/'+id+'?type=enable', method:'put', success:function(response, opts){ Ext.Sharera.msg("成功",'话题启用成功'); store.load(); }, failure:function(response, opts){ Ext.Sharera.error("错误",'话题启用失败'+message); } }); } }); }, getClass:function(v,o,r,rowIndex,colIndex,store){ if(!r.data.enabled){ return 'icon-coins-action'; } return 'x-hidden' } }]

转载于:https://my.oschina.net/kkrgwbj/blog/387405

你可能感兴趣的文章
iOS 图片填充 UIImageView
查看>>
spark2.3.0 配置spark sql 操作hive
查看>>
mysql常见错误解决方法
查看>>
【百度地图API】如何制作公交线路的搜索?如331路
查看>>
MusicXML 3.0 (30) - 和弦图表
查看>>
大话 char、varchar、 nchar、nvarchar之间"剪不断理还乱"的关系
查看>>
系统数据库
查看>>
JAVA: java产生随机数的几种方式
查看>>
调试发现的小错误
查看>>
c#中使用NetCDF存储二维数据的读写操作简单应用
查看>>
系统操作日志设计(转载)
查看>>
sqlldr 学习总结1
查看>>
剑指 offer set 17 判断一棵树是否是平衡树
查看>>
Leetcode: Path Sum II
查看>>
ShortcutMapper – 热门应用程序的可视化快捷键
查看>>
CSS3 实现的一个简单的"动态主菜单" 示例
查看>>
delphi 新版内存表 FDMemTable
查看>>
轻量级web富文本框——wangEditor使用手册(1)——基本应用 demo
查看>>
Java在的时候,类定义HashSet初始化方法
查看>>
利用JMX统计远程JAVA进程的CPU和Memory---jVM managerment API
查看>>