a232369
a232369
2009-10-22 14:22

ext 分页

已采纳

查询出的数据都有 我设置的是每页显示5条, 但是查出来后就显示前5条, 那个下一页的按钮不可以用 点不了.. 但是查出的数据是超过5条的 可能是我下面的代码写错了 但是我找不到 想请教一下有谁能找到不

[code="java"]
var employeeRecord;
var sm ;
var ds;
var ptb;
var cm;
var grid;
var searchPanel = new Ext.FormPanel({
labelAlign:'left',
id:'searchPanel',

name:'searchPanel',
title:'查询条件',
autoWidth:true,
autoHeight:true,
collapsible:true,
frame:true,

renderTo:document.body,

buttonAlign:'center',
monitorValid:true,
items:[
{

                        layout:'form',
                        border:false,
                        items:[
                               {
                                    columnWidth:.8,   
                                    xtype:'textfield',
                                    emptyText:'输入查询条件',
                                    width:200,
                                    allowBlank:false,
                                    blankText:'请输入查询条件',
                                    name:'conditionValue',
                                    id:'conditionValue',
                                    hiddenName:'conditionValue'


                               }
                        ],


   buttons:[
            {
                text:'提交',
                handler:function(){     


                    ds.proxy = new Ext.data.HttpProxy({
                        url:'/Lanto/GetEmployeeActionByCondition.action'
                    });
                    ds.render = new Ext.data.JsonReader({
                        root:'empList',
                        totalProperty:'total'
                    },employeeRecord);  
                    ds.load({
                        params:{
                            conditionValue:Ext.getCmp('conditionValue').value,
                            start:0,
                            limit:ptb.getPageSize()
                        }
                    });                                                                                     
            }                                                                                                               
            }                                       

            ]

}]

});

employeeRecord = new Ext.data.Record.create([
{name:'employeeID',mapping:'employeeID'},
{name:'employeeChineseName',mapping:'employeeChineseName'},
{name:'employeeEnglishName',mapping:'employeeEnglishName'},
{name:'employeePassword',mapping:'employeePassword'},
{name:'employeeIsAdministrator',mapping:'employeeIsAdministrator'},
{name:'employeeCompanyID',mapping:'employeeCompanyID'},
{name:'employeePositionID',mapping:'employeePositionID'},
{name:'employeeDepartmentID',mapping:'employeeDepartmentID'},
{name:'employeeSex',mapping:'employeeSex'},
{name:'employeeAge',mapping:'employeeAge'},
{name:'employeePhoto',mapping:'employeePhoto'},
{name:'employeeTelePhone',mapping:'employeeTelePhone'},
{name:'employeeExtension',mapping:'employeeExtension'},
{name:'employeeCornet',mapping:'employeeCornet'},
{name:'employeeQQ',mapping:'employeeQQ'},
{name:'employeeSkype',mapping:'employeeSkype'},
{name:'employeeOther',mapping:'employeeOther'},
{name:'employeeEmail',mapping:'employeeEmail'}

                                             ]);

sm = new Ext.grid.CheckboxSelectionModel({singleSelect:true});

//定义表格的列信息

cm = new Ext.grid.ColumnModel([

sm,
{id:'employeeID',dataIndex:'employeeID'},
{id:'employeeChineseName',header:'中文姓名',sortable:true,dataIndex:'employeeChineseName'},
{id:'employeeEnglishName',header:'英文名',sortable:true,dataIndex:'employeeEnglishName'},
{id:'employeePhoto',header:'分机号',sortable:true,dataIndex:'employeePhoto'},
{id:'employeeTelePhone',header:'手机',autoWidth:true,sortable:true,dataIndex:'employeeTelePhone'},

{id:'employeeExtension',header:'短号',sortable:true,dataIndex:'employeeCornet'},
{id:'employeeQQ',header:'QQ',sortable:true,dataIndex:'employeeQQ'},
{id:'employeeSkype',header:'Skype',sortable:true,dataIndex:'employeeSkype'},
{id:'employeeEmail',header:'Email',sortable:true,dataIndex:'employeeEmail'},
{id:'employeeOther',header:'其他',sortable:true,dataIndex:'employeeOther'}

]);
cm.setHidden(1,true);

//数据源
ds = new Ext.data.Store({
        proxy:new Ext.data.HttpProxy({
            url:'/Lanto/GetEmployeeActionByCondition.actions'
        }),
        reader:new Ext.data.JsonReader({
            root:'empList',
            totalProperty:'total'
        },employeeRecord)
    });

    ds.load({
        params:{

            start:0,
            limit:5
        }
    });
    ds.setDefaultSort('employeeID','ASC');

    //工具栏
  ptb = new Ext.PagingToolbar({
        plugins : new Ext.ux.Andrie.pPageSize(),
        showPreview:true,
        pageSize:5,//每页显示多少
        store:ds,
        displayInfo:true,
        displayMsg:'显示第 {0} 条到 {1} 条记录,一共 {2} 条',
        emptyMsg:'查询的记录为空!',
        firstText:'首页',
        prevText:'上一页',
        nextText:'下一页',
        lastText:'尾页',
        refreshText:'刷新'

    });
    //表格
        grid = new Ext.grid.GridPanel({
            id:'grid',
            border:false,
            buttonAlign:'right',
            autoWidth:true,
            autoHeight:true,
            ds:ds,
            cm:cm,
            sm:sm,
            stripeRows:true,//表格内部有线条
            loadMask:{msg:'数据加载中...'},
            enableDragDrop:true,//行拖动
            enableColumnHide:true,
            enableColumnMove:true,//列头可拖动
            enableColumnResize:true,//列头可改变大小
            collapsible:true,

            animCollapse: true,

            viewConfig:{
                forceFit:true,
                scrollOffset:20,//表格右侧为滚动条预留的宽度,默认20
                sortAscText:'升序',
                sortDescText:'降序',
                columnsText:'显示的列'
            },
            layoutConfig:{
                animate:true
            },
             tbar:[
            {
                id:'refresh',
                text:'刷新',
                tooltip:'刷新',
                iconCls:'table_refresh',
                onClick:function(){
                        ds.load({
                            params:{
                            start:0,
                            limit:5
                            }

                        });
                }               
            }
            ],

            bbar:ptb,
            autoHeight:true,
            width:765,
            frame:true,
            title:'人事档案信息',
            iconCls:'icon-grid',
            renderTo:document.body

        });
        grid.setPosition(0,0);

        //右键菜单代码
        grid.on('rowcontextmenu',rightClickFn);

        var rightClick = new Ext.menu.Menu({
            id:'rightClickMenu',
            items:[
                {
                    id:'menu5',
                    text:'刷新',
                    iconCls:'refresh',
                    handler:Ext.getCmp('refresh').onClick
                }
            ]
        });

    function rightClickFn(grid, rowindex, e) {
        e.preventDefault();
        rightClick.showAt(e.getXY());
    }

[/code]
[b]问题补充:[/b]
改了, 貌似还是不行..

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • lhx222 成尚謙 12年前

    你返回的JSON数据中没总记录数total:
    {"total":100,"empList":[{...},{...}]}

    点赞 评论 复制链接分享

相关推荐