In my Spring MVC application I have a data table, and I am using ajax and json to populate the data with pagination sorting etc. by the help of jquery.dataTables.js
. like this
$(document).ready(function() {
$("#accordion").hide();
$("#productList").dataTable({
"bProcessing" : true,
"iDisplayLength" : 10,
"iDisplayStart" : 0,
-------------
--------------
"sAjaxSource" : ....'/product/productList',
"aoColumns" : [ {
"mData" : "year"
}, {
"mData" : "catg"
}, {
"mData" : "name"
Where on table I am displaying 4 columns. Now On click on each row I want to show the details of selected record, around 50 fields.
I can achieve by jquery
, the time data table loading I can have get all the properties value to json
and can set each id of 50 fields on click of each record.
var table = $('#productList').DataTable();
$('#productList tbody').on('click', 'tr', function() {
$("#accordion").show();
var data = table.row(this).data();
$('#type').val(data.type);
$('#expdate').val(data.expDate);
$('#place').val(data.place);
$('#status').val(data.status);
But I want to use @ModelAttribute
or model
on click of a record It will do a ajax call set on ModelAttribute.so the deatils of record section will be inside form and each field have spring form path.
Is it possible?.please help on this.
You can modify this approach, because here they use hidden data.
All you need is replace row.child( format(row.data()) ).show();
with something like that: row.child( format(fetchDataFromServer(row.data().id)) ).show();
DataTable changed their API, so it have to be changed according to old API doc or you can switch to use new version of library.
UPD: Found a link to legacy API example. Here you'll need to modify fnFormatDetails
function invocation and pass data from server.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.