table.row( this ).data() is not working in java
table.row( this ).data() is not working in java
bux36
Posts: 1Questions: 0Answers: 0
debugger and console showing message that table.row is not a function
This discussion has been closed.
Replies
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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>Insert title here</title>
</head>
var editor; var id; $(document).ready(function () { /* $('#subject tbody').on('click', 'tr', function () { id = this.id; alert(id); } ); */ editor = new $.fn.dataTable.Editor({ ajax : { url : "./SubjectController", type : "POST", data : ""+id+"" }, table : "#subject", idSrc: "subjectId", fields : [ { label : "Name", name : "name" }, { label : "Description", name : "description" } ] }); var table = $("#subject").dataTable({ dom : "Bfrtip", ajax : { url : "./SubjectController", type : "POST" }, rowId : "subjectId", serverSide : true, processing : true, columns: [ { "data": "subjectId" }, { "data": "name" }, { "data": "description" } ], select : true, buttons : [ { extend : "create" , editor : editor}, { extend : "edit" , editor : editor}, { extend : "remove" , editor : editor} ], "sPaginationType": "full_numbers" }); $('#subject tbody').on( 'click', 'tr', function () { alert( table.row( this ).data() ); } ); });<body>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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>Insert title here</title>
</head>
var editor; var id; $(document).ready(function () { /* $('#subject tbody').on('click', 'tr', function () { id = this.id; alert(id); } ); */ editor = new $.fn.dataTable.Editor({ ajax : { url : "./SubjectController", type : "POST", data : ""+id+"" }, table : "#subject", idSrc: "subjectId", fields : [ { label : "Name", name : "name" }, { label : "Description", name : "description" } ] }); var table = $("#subject").dataTable({ dom : "Bfrtip", ajax : { url : "./SubjectController", type : "POST" }, rowId : "subjectId", serverSide : true, processing : true, columns: [ { "data": "subjectId" }, { "data": "name" }, { "data": "description" } ], select : true, buttons : [ { extend : "create" , editor : editor}, { extend : "edit" , editor : editor}, { extend : "remove" , editor : editor} ], "sPaginationType": "full_numbers" }); $('#subject tbody').on( 'click', 'tr', function () { alert( table.row( this ).data() ); } ); });<body>
</body>
</html>
Use
DataTable()
to initialize your table instead ofdataTable()
.For example:
See more articles about jQuery DataTables on gyrocode.com.
Yup:
is the issue. See the top FAQ .
Allan