-
-
-
-
-
-
-
-
-
-
- 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:"發(fā)布人ID",
-
- visiable: true
-
- },{
-
- header: '標題',
-
- width: 80,
-
- dataIndex: 'bt',
-
- visiable: true
-
- }, {
-
- header: '發(fā)布時間',
-
- width: 80,
-
- dataIndex: 'fbsj',
-
- visiable: true
-
- }, {
-
- header: '發(fā)布人員',
-
- 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: '點擊數(shù)',
-
- 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 : '刪除所選數(shù)據(jù)',
-
- 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("成功","用戶數(shù)據(jù)刪除成功!");
-
- myGrid.recordIds = new Array();
-
- myGrid.store.load({params:{start:0,limit:15}});
-
- });
-
- }
-
- }
-
- );
-
- }
-
- }
-
- }]
-
- });
-
-
-
- myGrid.render();</PRE>
- 下載地址如下<A>http:
|