-
-
-
-
-
-
-
-
-
-
- Ext.namespace('Ext.ux.grid');
-
-
-
- Ext.ux.grid.MyGrid = Ext.extend(Ext.grid.GridPanel,{
-
-
-
-
-
-
-
-
-
-
-
-
-
- keepSelectedOnPaging: false,
-
-
-
-
-
-
-
-
-
-
-
- recordIds:new Array(),
-
-
-
-
-
-
-
-
-
-
-
- idColName:'',
-
-
-
-
-
-
-
-
-
-
-
- url: '',
-
-
-
-
-
-
-
-
-
-
-
-
-
- rowNumber : true,
-
-
-
-
-
-
-
-
-
-
-
-
-
- checkBox: true,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- CM_JR_Record: null,
-
-
-
-
-
-
-
-
-
-
-
-
-
- pagingBar: true,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- pagingConfig:{
-
- pageSize: 15,
-
- store: this.store,
-
- displayInfo: true,
-
- displayMsg: "显示第 {0} 条到 {1} 条记录,一共 {2} 条",
-
- emptyMsg: '<b>0</b> 条记录',
-
- },
-
-
-
- viewConfig:{
-
- forceFit: true
-
- },
-
-
-
-
-
- initComponent: function(){
-
- if(this.CM_JR_Record){
-
- this.init_SM_CM_DS();
-
- }
-
- if(this.pagingBar){
-
- this.init_PagingBar();
-
- }
-
- if(this.keepSelectedOnPaging){
-
- this.init_OnPaging();
-
- }
-
- Ext.ux.grid.MyGrid.superclass.initComponent.call(this);
-
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
- init_SM_CM_DS: function(){
-
- var gCm = new Array();
-
- var gRecord = new Array();
-
-
-
- if(this.rowNumber){
-
- gCm[gCm.length]=new Ext.grid.RowNumberer();
-
- }
-
- if(this.checkBox){
-
- var sm = new Ext.grid.CheckboxSelectionModel();
-
- gCm[gCm.length] = sm;
-
- this.selModel = sm;
-
- }
-
-
-
- for(var i=0;i<this.CM_JR_Record.length;i++)
-
- {
-
- var g = this.CM_JR_Record[i];
-
- if(g.visiable || g.visiable=='undefined' || g.visiable==null){
-
- gCm[gCm.length] = g;
-
- }
-
-
-
- gRecord[gRecord.length]={
-
- name: g.dataIndex,
-
- type: g.type || 'string'
-
- }
-
- }
-
-
-
-
-
- this.cm = new Ext.grid.ColumnModel(gCm);
-
- this.cm.defaultSortable = true;
-
-
-
-
-
- this.store = new Ext.data.Store({
-
- proxy: new Ext.data.HttpProxy({
-
- url: this.url,
-
- method: 'post'
-
- }),
-
- reader:new Ext.data.JsonReader({
-
- totalProperty: 'total',
-
- root: 'list'
-
- },
-
- Ext.data.Record.create(gRecord)
-
- )
-
-
-
- });
-
-
-
-
-
- this.pagingConfig.store = this.store;
-
-
-
- if(this.pagingBar){
-
- this.store.load({params:{start:0,limit:this.pagingConfig.pageSize}});
-
- }else{
-
- this.store.load();
-
- }
-
-
-
- },
-
-
-
-
-
-
-
-
-
- init_PagingBar: function(){
-
- var bbar = new Ext.PagingToolbar(this.pagingConfig);
-
- this.bbar = bbar;
-
- },
-
-
-
- init_OnPaging: function(){
-
-
-
- this.idColName = this.CM_JR_Record[0].dataIndex ;
-
-
-
- this.selModel.on('rowdeselect',function(selMdl,rowIndex,rec ){
-
-
-
-
-
- for(var i=0;i<this.recordIds.length;i++)
-
- {
-
- if(rec.data[this.idColName] == this.recordIds[i]){
-
- this.recordIds.splice(i,1);
-
- return;
-
- }
-
- }
-
-
-
-
-
- },this);
-
-
-
- this.selModel.on('rowselect',function(selMdl,rowIndex,rec){
-
- if(this.hasElement(this.recordIds)){
-
- for(var i=0;i<this.recordIds.length;i++){
-
- if(rec.data[this.idColName] == this.recordIds[i]){
-
- return;
-
- }
-
- }
-
- }
-
-
-
- this.recordIds.unshift(rec.data[this.idColName]);
-
-
-
- },this);
-
-
-
- this.store.on('load',function(st,recs){
-
- if(this.hasElement(this.recordIds)){
-
- st.each(function(rec){
-
- Ext.each(this.recordIds,function(item,index,allItems){
-
- if(rec.data[this.idColName] == item){
-
- this.selModel.selectRecords([rec],true);
-
- return false;
-
- }
-
- },this);
-
- },this);
-
- }
-
- },this);
-
-
-
- },
-
-
-
- hasElement : function(recIds){
-
- if(recIds.length > 0)
-
- return true;
-
- else
-
- return false;
-
- }
-
-
-
- }
-
- )<SPAN style="FONT-FAMILY: Arial, Verdana, Sans-Serif">
-
-
- <SPAN style="FONT-FAMILY: Arial, Verdana, Sans-Serif"><PRE class=jscript name="code">var CM_JR_Record = [
-
- {
-
- dataIndex:"id",
-
- visiable: false
-
- },{
-
- dataIndex:"accid",
-
- header:"发布人ID",
-
- visiable: true
-
- },{
-
- header: '标题',
-
- width: 80,
-
- dataIndex: 'bt',
-
- visiable: true
-
- }, {
-
- header: '发布时间',
-
- width: 80,
-
- dataIndex: 'fbsj',
-
- visiable: true
-
- }, {
-
- header: '发布人员',
-
- width: 80,
-
- dataIndex: 'fbry',
-
- visiable: true
-
- }, {
-
- header: '审核',
-
- width: 80,
-
- dataIndex: 'sh',
-
- visiable: true
-
- }, {
-
- header: '审核人员',
-
- width: 80,
-
- dataIndex: 'shry',
-
- visiable: true
-
- }, {
-
- header: '审核时间',
-
- width: 80,
-
- dataIndex: 'shsj',
-
- visiable: true
-
- }, {
-
- header: '点击数',
-
- width: 80,
-
- dataIndex: 'snum',
-
- visiable: true
-
- }];
-
-
-
- var myGrid = new Ext.ux.grid.MyGrid({
-
- url : '/ecommerce/findAllBulletin.action',
-
- CM_JR_Record: CM_JR_Record,
-
- rowNumber:true,
-
- checkBox:true,
-
- pagingBar:true,
-
-
-
- keepSelectedOnPaging: true,
-
- recordIds : new Array() ,
-
- idColName :'id',
-
- width : 700,
-
- height: 600,
-
- renderTo: 'editor-grid',
-
- tbar: [{
-
- id : 'Add',
-
- text : ' 新建 ',
-
- tooltip : '新建一个表单',
-
- iconCls : 'add',
-
- pageSize: 15,
-
- handler : function(){
-
- ptb_bt1();
-
- }
-
- },{
-
- text: '删除所选',
-
- iconCls:'remove',
-
- tooltip : '删除所选数据',
-
- handler : function(){
-
-
-
- if(myGrid.recordIds.length == 0){
-
- Ext.MessageBox.alert('提示','请选择一条记录!');
-
- }else{
-
-
-
- Ext.MessageBox.confirm('确认删除',
-
- '你真的要删除所选用户吗?',
-
- function(btn){
-
- if(btn == 'yes') {
-
-
-
- bulletinService.delBulletin(myGrid.recordIds.toString(), function() {
-
-
-
- Ext.Msg.alert("成功","用户数据删除成功!");
-
- myGrid.recordIds = new Array();
-
- myGrid.store.load({params:{start:0,limit:15}});
-
- });
-
- }
-
- }
-
- );
-
- }
-
- }
-
- }]
-
- });
-
-
-
- myGrid.render();</PRE>
- 下载地址如下<A>http:
|