vendredi 28 novembre 2014

jquery dataTable return [object Object]


I have this code to create datatable with datatables jquery plugin





<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://ift.tt/18bwTB1" prefix="spring"%>
<%@taglib uri="http://ift.tt/IED0jK" prefix="form"%>
<%@taglib uri="http://ift.tt/QfKAz6" prefix="c"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://ift.tt/kTyqzh">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<style type="text/css">
<%@ include file="/Css/style.css" %>
<%@ include file="/Css/jquery.dataTables.css" %>

</style>


<title>Student Management</title>


<script src="< c:url value="/js/jquery-1.10.2.min.js"/>" > </script>
<script src="< c:url value="/js/jquery.dataTables.js"/>" > </script>

<script type="text/javascript">


var tab;

//Plug-in to fetch page data
jQuery.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
{
return {
"iStart": oSettings._iDisplayStart,
"iEnd": oSettings.fnDisplayEnd(),
"iLength": oSettings._iDisplayLength,
"iTotal": oSettings.fnRecordsTotal(),
"iFilteredTotal": oSettings.fnRecordsDisplay(),
"iPage": oSettings._iDisplayLength === -1 ?
0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
"iTotalPages": oSettings._iDisplayLength === -1 ?
0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )

};
};
var idEdit;







function tst (){

$("#example").dataTable( {
"idEditt":2,
"bProcessing": true,
"bServerSide": true,
"sort": "position",
//bStateSave variable you can use to save state on client cookies: set value "true"
"bStateSave": false,
//Default: Page display length
"iDisplayLength": 10,
//We will use below variable to track page number on server side(For more information visit: http://ift.tt/1pxfATK)
"iDisplayStart": 0,

"fnDrawCallback": function () {
//Get page numer on client. Please note: number start from 0 So
//for the first page you will see 0 second page 1 third page 2...
//Un-comment below alert to see page number
//alert("Current page number: "+this.fnPagingInfo().iPage);
},

"sAjaxSource": "springPaginationDataTables.sqli",


"aoColumns": [

{ "mData": "studentId" },
{ "mData": "firstname" },
{ "mData": "lastname" },
{ "mData": "yearLevel" },
{

"data":null,

"defaultContent":"<form action='edit.sqli' method='post'><input type='texte' name='idEdit' value='cc' /> <input type='submit' value='ok' onclick='javascript:clique();' / > </form><a href='#'> <img src='<%=request.getContextPath()%>/images/delete.png' width='30 px' height='20px' /> </a>"


}],




} );



I need to get row index so I write as you can see code above:





$(document).ready(function() {

tst ();
var tab= $('#example').dataTable();

var nNodes = tab.api().row(3).data();

alert (nNodes);



but this code return only [object Object], Sombody have explanation? i need your help plz





Aucun commentaire:

Enregistrer un commentaire