2015-11-23 2 views
0

Я пытаюсь показать данные в своей jtable, но он просто показывает количество строк в моей таблице, но не данные. мой JSP выглядитjquery jtable, не показывающий результаты

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
    pageEncoding="ISO-8859-1"%> 

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<title>jtable integration</title> 

<%-- JQuery --%> 
<script src="<c:url value="/js/jquery-1.8.2.js" />"></script> 
<script src="<c:url value="/js/jquery-ui-1.10.4.custom.js" />"></script> 

<%-- Jtable --%> 

<script src="<c:url value="/js/Utility.js" />"></script> 
<script src="<c:url value="/js/jTable/jquery.jtable.js" />"></script> 
<script src="<c:url value="/js/jTable/jquery.jtable.min.js" />"></script> 
<script src="<c:url value="/js/StudentJtable.js" />"></script> 

<link href="<c:url value="/css/jquery-ui-1.10.4.custom.css" />" 
    rel="stylesheet"> 
<link href="<c:url value="/js/jTable/Themes/Metro/blue/jtable.css" />" 
    rel="stylesheet"> 


</head> 
<body> 
<h1>hi</h1> 
    <div> 
     <div id="StudentTableContainer" style="width: 99%;"></div> 
    </div> 

    <button onclick="myFunction()"></button> 
    <label id="test">tttt</label> 

</body> 
</html> 

studenttable.js

$(document).ready(function() {    
    //setup the jtable that will display the results 
    $('#StudentTableContainer').jtable({ 
     title: 'Table of Student', 
     selecting: true, //Enable selecting 
     paging: true, //Enable paging 
     pageSize: 10, //Set page size (default: 10) 
     sorting: true, //Enable sorting 
     actions: { 
      listAction: 'datatable/getAllStudents', 
     }, 
     fields: { 
      ID: { 
       title: 'iD', 
       key: true, 
       list: true, 
       create: false, 
       edit: false 
      }, 
      NAME: { 
       title: 'name', 
       width: '50%' 
      }, 
      AGE: { 
       title: 'age', 
       width: '30%' 
      } 

     } 

    }); 
    $('#StudentTableContainer').jtable('load');    

}); 

модель студента

package com.model; 

import java.util.Date; 

    public class Student { 
     private Integer age; 
      private String name; 
      private Integer id; 

      public void setAge(Integer age) { 
       this.age = age; 
      } 
      public Integer getAge() { 
       return age; 
      } 

     public void setName(String name) { 
       this.name = name; 
      } 
      public String getName() { 
       return name; 
      } 

      public void setId(Integer id) { 
       this.id = id; 
      } 
      public Integer getId() { 
       return id; 
      } 
    } 

контроллер

@RequestMapping(value = "datatable/getAllStudents", method = RequestMethod.POST, produces="application/json") 
    @ResponseBody 
    public JsonJtableStudentListResponse getAllExpenses(@RequestParam int jtStartIndex, @RequestParam int jtPageSize) { 
     JsonJtableStudentListResponse jstr; 
     int count= 0; 
     List<Student> students= studentDaoImp.getStudents(); 
     count=students .size(); 
     jstr = new JsonJtableStudentListResponse("OK",students,count); 
     return jstr; 
     //return new JsonJtableResponse().ok(students); 
    } 

есть всего 9 записей в таблице и м y jtable i показывает 9 строк, но данных нет.

Может кто-нибудь помочь мне, я просто изучаю это сейчас. благодарит заранее.

ответ

0

Извините, я сделал самую глупую ошибку.

$(document).ready(function() {    
    //setup the jtable that will display the results 
    $('#StudentTableContainer').jtable({ 
     title: 'Table of Student', 
     selecting: true, //Enable selecting 
     paging: true, //Enable paging 
     pageSize: 10, //Set page size (default: 10) 
     sorting: true, //Enable sorting 
     actions: { 
      listAction: 'datatable/getAllStudents', 
     }, 
     fields: { 
      ID: { 
       title: 'iD', 
       key: true, 
       list: true, 
       create: false, 
       edit: false 
      }, 
      NAME: { 
       title: 'name', 
       width: '50%' 
      }, 
      AGE: { 
       title: 'age', 
       width: '30%' 
      } 

     } 

    }); 
    $('#StudentTableContainer').jtable('load');    

}); 

Я использовал капители в своих js и маленькие в своем модельном столе.

Смежные вопросы