loading detail record through ajax

loading detail record through ajax

mzguptamzgupta Posts: 5Questions: 0Answers: 0
edited October 2010 in General
Hi All,
I would like to share some code. First we load tables and after that it uses ajax call to load detail record for row.
This way we can divide data processing at both the end equally
[code]
<%@ 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 uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">



Insert title here

@import "css/demo_page.css";
@import "css/demo_table.css";





$(document).ready(function() {
var oTable=$('#example').dataTable({
"bProcessing" : true
});
$('#example tbody td img').bind('click', function () {
var nTr = this.parentNode.parentNode;
var aData = oTable.fnGetData( nTr );
if ( this.src.match('details_close') )
{
/* This row is already open - close it */
this.src = "http://datatables.net/examples/examples_support/details_open.png";
oTable.fnClose( nTr );
}
else
{
/* Open this row */
this.src = "http://datatables.net/examples/examples_support/details_close.png";
$.ajax({
url: './groups',
data: {'libraryID':aData[1]},
success: function(data){oTable.fnOpen( nTr, data, 'details' );},
dataType: 'text'
});
}
} );
});




DataTables For SAS Libraries
SAS





Library ID
Library Name
Library Description
Library Owner






${library.libraryID}
${library.libraryName}
${library.libraryDesc}

${owner.userName}







Library ID
Library Name
Library Description
Library Owner









[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Nice one - thanks very much for sharing this with us!

    Regards,
    Allan
This discussion has been closed.