Reg. Pagination
Reg. Pagination
thaneshkadi
Posts: 5Questions: 0Answers: 0
Hi
I am new to DataTables. I want to do pagination for a table. Let me tell you what this table is and how i created it.
I have a XML file which contains all the employee details. I used jquery to create a table using a ajax request. I have created Employee table in DataTables formate.
My question is how to use pagination for this table. Can some one point me in right direction
thanks
Kumar
I am new to DataTables. I want to do pagination for a table. Let me tell you what this table is and how i created it.
I have a XML file which contains all the employee details. I used jquery to create a table using a ajax request. I have created Employee table in DataTables formate.
My question is how to use pagination for this table. Can some one point me in right direction
thanks
Kumar
This discussion has been closed.
Replies
Have a look at this demo, which shows how to initialise DataTables with most of the features enabled: http://datatables.net/examples/basic_init/zero_config.html . This demo shows how you can disable some features: http://datatables.net/examples/basic_init/filter_only.html .
Regards,
Allan
Thanks for the reply. I did all the above things already but i am not getting the pagination. Below is the script what i have used to get the xml from the server and generating the table by parsing the XML . But i cant get the pagination. can you please help me in this issues. Please let me know, can we use pagination for a table which is generated on the fly by parsing the xml which i have received through xmlhttprequest.
[code]
$(document).ready(function(){
$("#submit").click(function(){
var query=document.getElementById("query").value;
if(query!=''){
$.ajax({
type: "GET",
url: "http://localhost:8080/ClientServlet?query="+query,
dataType:"xml",
timeout: 60000,
error: function(xmlhttpreq, textStatus, errorThrown){
alert("error:"+textStatus+":ErrorThrown:"+errorThrown+":Status:"+xmlhttpreq.status);
},
success: function(msg){
var datarow="";
var multirows="";
var heading="";
var metarow="";
$("#data").dataTable();
alert("entering ajax");
$(msg).find("ResultSet").each(function(){
$(this).find("MetaData").each(function(){
$(this).find("column").each(function(){
metarow = metarow +("" + $(this).text() + "");
});
heading = "" + metarow + "";
});
$(this).find("Data").each(function(){
$(this).find("Row").each(function(){
datarow = "";
$(this).find("column").each(function(){
datarow =datarow+("" + $(this).text() + "");
});
datarow = datarow + "";
multirows = multirows + datarow;
});
});
});
$("#data").html("" + heading + "" + multirows + "");
}
});
}
});
});
[/code]
Below is my html
[code]
Enter the Query for the table:
[/code]
I am getting big big tables tooo so i am trying to look into JSON also as i gone through some of your dissusions on this forums and lot of them recommend that it would be nice to use JSON
Please help me in this
Thanks
Kumar
It looks like you are initialising DataTables before you parse the XML into the HTML table. Try initialising DataTables once there is data in there for it to parse. Alternatively you could use fnAddData if you prefer to do it that way.
Regards,
Allan
Thanks for the help it worked out. I initialized the dataTable in a wrong place. any way thanks for the help.
Thanks
Kumar