Мне нужно создать несколько таблиц данных для каждого jsonobject [который представляет собой еженедельные данные о присоединении] в jsonarray.
, хотя по запросу ajax я получаю массив JSON из java.Как я могу создать несколько таблиц данных для каждого json-объекта [для данных каждой недели]?Пожалуйста, помогите мне в этой проблеме.
jQuery(document)
.ready(
function () {
jQuery(".ui-corner-br")
.addClass('ui-widget-header_custom ');
$('#btnShow')
.click(
function (event) {
event.preventDefault();
var month = $("#month").val();
var year = $("#year").val();
ajaxResource = "/secure/attendance/get-employee-work-hours-report.json?month=" + month + " & year = " + year;
$(" # searchDataFrm ").attr(" action ", ajaxResource);
employeeWorkHours(ajaxResource);
});
});
function employeeWorkHours(ajaxResource) {
jQuery.unblockUI();
employeeWorkHoursTable = jQuery('#employeeWorkHoursTableWeekOne')
.dataTable({
" bJQueryUI " : true,
" sPaginationType " : " full_numbers ",
" iDisplayLength " : 250,
" bSort " : true,
" bLengthChange " : true,
" bProcessing " : true,
" bServerSide " : true,
" bAutoWidth " : false,
" bDestroy " : true,
" bRetrieve " : false,
" sAjaxSource " : basePath + ajaxResource,
" fnServerData " : fnServerData,
" aoColumns " : [ {
" sWidth " : " 15 % ",
" bSortable " : true,
" bSearchable " : false
}, // Date
{
" sWidth " : " 25 % ",
" bSortable " : true
}, // Day
{
" sWidth " : " 20 % ",
" bVisible " : true,
" bSearchable " : false
}, // 1st In
{
" sWidth " : " 20 % ",
" bSearchable " : false
}, // Last In
{
" sWidth " : " 20 % ",
" bSearchable " : false
} // Work Hours
],
" fnDrawCallback " : function(oSettings) {
}
});
jQuery(".ui - corner - br ").addClass('ui-widget-header_custom ');
jQuery('.dataTables_length').hide();
$(" # employeeWorkHoursTableWeekOne_first ").html(" << ");
$(" # employeeWorkHoursTableWeekOne_previous ").html(" < ");
$(" # employeeWorkHoursTableWeekOne_next ").html(" > ");
$(" # employeeWorkHoursTableWeekOne_last ").html(" >> ");
}
function fnServerData(sSource, aoData, fnCallback) {
isSessionExtend = true;
if (xhr && xhr.readystate != 4) {
xhr.abort();
}
xhr = $.ajax({
" dataType " : 'json',
" type " : " GET ",
" url " : sSource,
" contentType " : 'application/json',
" data " : aoData,
" success " : fnCallback,
" timeout " : 20000,
" cache " : false,
" error " : handleAjaxError
});
jQuery('html, body').animate({
scrollTop : '0px'
}, 300);
}
JSON Array:
[{
"iTotalRecords": 0,
"aaData": [],
"iTotalDisplayRecords": 0,
"status": "OK"
},
{
"iTotalRecords": 0,
"aaData": [],
"iTotalDisplayRecords": 0,
"status": "OK"
},
{
"iTotalRecords": 5,
"aaData": [["13/11/2018", "13/11/2018", "10:33", "21:17", "09:20", 3],
["14/11/2018", "14/11/2018", "10:48", "21:48", "09:36", 3],
["15/11/2018", "15/11/2018", "14:46", "22:07", "07:21", 3],
["16/11/2018", "16/11/2018", "12:19", "20:32", "07:21", 3],
["17/11/2018", "17/11/2018", "11:23", "17:05", "05:42", 3]],
"iTotalDisplayRecords": 5,
"status": "OK"
},
{
"iTotalRecords": 6,
"aaData": [["01/12/2018", "01/12/2018", "11:58", "18:32", "05:56", 5],
["26/11/2018", "26/11/2018", "10:34", "19:23", "08:49", 5],
["27/11/2018", "27/11/2018", "11:30", "21:01", "09:31", 5],
["28/11/2018", "28/11/2018", "11:07", "19:53", "07:54", 5],
["29/11/2018", "29/11/2018", "18:14", "20:48", "02:34", 5],
["30/11/2018", "30/11/2018", "14:46", "21:38", "06:52", 5]],
"iTotalDisplayRecords": 6,
"status": "OK"
}]