煊钺季枫铘 2015-10-29 08:53
浏览 547

datagrid生成数据表格,可以显示有多少条,也可以删除,但是数据显示不出来。

var dg;
$(function() {
dg = $('#vehicle_datagrid').datagrid( {
title : '',
iconCls : 'icon-save',
pagination : true,
pageSize : 10,
pageList : [ 10, 20, 30, 40 ],
fit : true,
fitColumns : true,
nowrap : false,
border : false,
idField : 'id',
singleSelect : false,
iconCls : 'icon-save',
rownumbers : true,
url : '${pageContext.request.contextPath}/findVehicle.action?',
pagePosition : 'bottom',
toolbar : '#vehicle_toolbar',
loadMsg : '正在加载数据当中....',
frozenColumns : [ [ {
field : 'id',
title : '编号',
width : 100,
checkbox : true
}] ],
columns : [ [
{
field : 'UserName',
title : '姓名',
width : 100,
align : "center"
},{
field : 'IdCard',
title : '身份证号',
width : 150,
align : "center"

    } , {
        field : 'VehicleNumber',
        title : '车号',
        width : 100,
        align : "center"
    }, {
        field : 'Phone',
        title : '电话号码',
        width : 150,
        align : "center"
    }, {
        field : 'StartTime',
        title : '开始时间',
        width : 150,
        align : "center"
    }, {
        field : 'EndTime',
        title : '结束时间',
        width : 150,
        align : "center"
    } ,{
        field : 'Money',
        title : '金额',
        width : 150,
        align : "center"
    }] ],
    toolbar : "#vehicle_toolbar"
});

});
//这是表格

//这是action
//获取列表
@Action(value = "findVehicle")
public void findVehicle() {
super.writeJson(vehicleRentServices.datagrid(vehicle));
}
//业务层
@Override
public DataGrid datagrid(VehicleRentModel vehicle) {
DataGrid j = new DataGrid();
j.setRows(this.changeModel(this.find(vehicle)));
j.setTotal(this.total(vehicle));
return j;
}

private List<VehicleRentModel> changeModel(List<VehicleRent> vehicleList) {
    List<VehicleRentModel> vehicleRentModelList = new ArrayList<VehicleRentModel>();
    if (vehicleList!= null && vehicleList.size() > 0) {
        for (VehicleRent v : vehicleList) {
            VehicleRentModel vr = new VehicleRentModel();
            BeanUtils.copyProperties(v, vr); // 拷贝属性
            vehicleRentModelList.add(vr);
        }
    }
    return vehicleRentModelList;
}

private List<VehicleRent> find(VehicleRentModel vehicle) {
    String hql = "from VehicleRent v where 1=1";
    List<Object> values = new ArrayList<Object>();
    // 查询条件
    hql = addWhere(vehicle, hql, values);
    // 是否排序 按照什么排序
    if (vehicle.getSort() != null && vehicle.getOrder() != null) {
        hql += " order by " + vehicle.getSort() + " " + vehicle.getOrder();
    }
    // 分页查询
    return bd.find(hql, values, vehicle.getPage(),
            vehicle.getRows());
}
private Long total(VehicleRentModel vehicle) {
    String hql = "select count(*) from VehicleRent v where 1=1  ";

    List<Object> values = new ArrayList<Object>();
    hql = addWhere(vehicle, hql, values);
    return bd.count(hql, values);
}
  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥20 5037端口被adb自己占了
    • ¥15 python:excel数据写入多个对应word文档
    • ¥60 全一数分解素因子和素数循环节位数
    • ¥15 ffmpeg如何安装到虚拟环境
    • ¥188 寻找能做王者评分提取的
    • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
    • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
    • ¥15 写论文,需要数据支撑
    • ¥15 identifier of an instance of 类 was altered from xx to xx错误
    • ¥100 反编译微信小游戏求指导