I use Datatables 1.10. How can I set the limit of display number of rows?
I have 1000 rows that are all showing on one page. At Datatables 1.9 it was going with 'iDisplaylenght'. But in Datatable 1.10 I've tried to set 'lenght:10' like in this documentation: http://next.datatables.net/manual/server-side but it doesn't work.
on this link above you can see my problem. It doesn't matter which number I choose from the checkbox.
I have found out, with the link from @Julian(thanks), that if I don´t use the ajax call, it works fine. But if I get my data from the server-side all of my data are showing. See the link. So it must be a problem on the server-side?!
@SuppressWarnings("unchecked")
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String sql = "SELECT UID,LastName,FirstName FROM employe LIMIT 1000";
int rows=0;
int count = 0;
JSONArray arrayback = new JSONArray();
JSONObject object = new JSONObject();
PrintWriter out = response.getWriter();
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/check","****","****");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
ResultSetMetaData meta = rs.getMetaData();
rows= meta.getColumnCount();
while(rs.next())
{
JSONArray array = new JSONArray();
array.add(rs.getString("UID"));
array.add(rs.getString("LastName"));
array.add(rs.getString("FirstName"));
count++;
arrayback.add(array);
}
object.put("aaData", arrayback);
object.put("sEcho",1);
object.put("iTotalRecords", count);
object.put("iTotalDisplayRecords", count);
out.print(object);
con.close();
}catch(exception e)
{
e.printStackTrace();
}
}
This is my server code.