您的位置:首页 > 其它

动态改变GridPanel分页数量 combobox

2014-02-25 11:15 337 查看
var pageSize = 10;  //分页数
 

//=====================选择分页数的ComboBox======
var pagesize_combo = new Ext.form.ComboBox({   

     store:new Ext.data.SimpleStore({

      fields:["text","value"],

      data:[["5","5"],["10","10"],["12","12"],["15","15"],["20","20"],["30","30"]]

     }),   

     width:50,   

     readOnly:true,   

     emptyText: '10',   

     mode:"local",    

     triggerAction: 'all',   

     valueField: 'value',   

     displayField: 'text'  

});   


//下拉列表事件,更改pageSize.重新加载   

pagesize_combo.on("select",function(comboBox){

        BBar.pageSize = parseInt(comboBox.getValue());

        RoleInfoStore.reload({params:{start:0,limit:BBar.pageSize}});
}); 


//=====================分页条===================

var BBar=new Ext.PagingToolbar({

   store:RoleInfoStore,

   pageSize:pageSize,

   //显示右下角信息

   displayInfo:true,

   displayMsg:'当前记录 {0} -- {1} 条 共 {2} 条记录',

      emptyMsg:"No results to display",

      prevText:"上一页",

   nextText:"下一页",

   refreshText:"刷新",

   lastText:"最后页",

   firstText:"第一页",

   beforePageText:"当前页",

   afterPageText:"共{0}页",

   items:[

         '  每页显示记录数量:',   

                  pagesize_combo
   ]  

  });


var RoleGrid = new Ext.grid.GridPanel({

  id:"RoleGrid",

  store:RoleInfoStore,

  sm:sm,

  cm:cm,

  loadMask:true,

  stripeRows:true,

  height:gridHeight,

  autoScroll:true,

  border:false,

  viewConfig:{

       columnsText:"显示/隐藏列",

       sortAscText:"正序排列",

       sortDescText:"倒序排列",

       forceFit:true,

       enableRowBody:true,

       getRowClass:function(record,rowIndex,p,ds){

                        

                         if(rowIndex%2==0)

                               return "RowStyle";

                         else  return "AlternatingRowStyle"; //css 样式   

      

       }

  },

  //=====================分页条===========

  bbar:BBar,


  listeners:{

            'contextmenu':function(e)

            {

                e.stopEvent();

            }

  }

 });
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: