2017-08-09 89 views
0

這是我在JSP中的DataGrid部分:DataGrid不顯示數據

<title>Device</title> 
<script type="text/javascript"> 
var dataGrid; 
$(function() { 
    dataGrid = $('#dataGrid').datagrid({ 
     url : '${ctx}' + '/drivers/dataGrids', 
     striped : true, 
     rownumbers : true, 
     pagination : true, 
     singleSelect : true, 
     idField : 'id', 
     sortName : 'driversstatus', 
     sortOrder : 'desc', 
     pageSize : 15, 
     pageList : [ 10, 20, 30, 40, 50, 100, 200, 300, 400, 500 ], 
     frozenColumns : [ [ { 
      width : '100', 
      title : 'id', 
      field : 'id', 
      sortable : true 
     }, { 
      width : '80', 
      title : 'Device Name', 
      field : 'driversname', 
      sortable : true 
     } , { 
      width : '80', 
      title : 'Device ip', 
      field : 'driversip', 
      sortable : true 
     }, { 
      width : '80', 
      title : 'Device type', 
      field : 'driverstype', 
      sortable : true, 
     }, { 
      width : '80', 
      title : 'Device Status', 
      field : 'driversstatus', 
      sortable : true, 
      formatter : function(value, row, index) { 
       switch (value) { 
       case 0: 
        return 'Online'; 
       case 1: 
        return 'Offline'; 
       } 
      } 
     } ,{ 
      width : '80', 
      title : 'Add Time', 
      field : 'addtime', 
      sortable : true, 
     } 
     ] ], 
     toolbar : '#toolbar' 
    }); 
}); 

這裏是在控制器類我的DataGrid代碼:

@RequestMapping("/dataGrids") 
@ResponseBody 
public Grid jsonList(Drivers eqimInfo, PageFilter ph) { 
    Grid grid = new Grid(); 
    grid.setPage(ph.getPage()); 
    grid.setRows(driversService.dataGrid(eqimInfo, ph)); 
    grid.setTotal(driversService.Count(eqimInfo, ph)); 
    return grid; 
} 

Grid.class包含私有屬性,包括頁面,行和rowsCount,以及它們的getter和setter; Drivers.class是數據類。

我可以確認返回的Grid實例包含從數據庫中檢索到的每個數據,但奇怪的是每列都顯示了它們的值,除了「Device Name」列之外,這讓我瘋狂......

有什麼建議嗎?

回答

0

問題已解決。事實證明,mySQL中的字段的第一個字母應該使用小寫,否則jsp將無法識別它。