jQuery Datatable header and body width mismatch withcollapsed sidebar - javascript

I have a datatable and a collapsible sidebar. The table has table-layout:fixed and I defined all of the columns width in my css. The table looks perfect when the sidbar is collapsed, but if the sidebar is opened, the column and header is misaligned. When i open firebug, I see that dataTables_scrollHeadInner has width: 1558px; but dataTables_scrollBody has width: 1343px. I have no idea why the header isn't getting resized along with the body. All codes are below (the HTML is being generated dynamically and too big to paste here):
Javascript:
$(document).ready(function () {
var selector = "#artist_datatable";
var defaults = {
"language": {
"processing": "Processing...",
"lengthMenu": "Show _MENU_ entries",
"zeroRecords": "No matching records found",
"info": "Showing _START_ to _END_ of _TOTAL_ entries",
"infoEmpty": "Showing 0 to 0 of 0 entries",
"sInfoFiltered": "(filtered from _MAX_ total entries)",
"infoPostFix": "",
"search": "Search",
"url": "",
"paginate": {
"first": "First",
"previous": "Previous",
"next": "Next",
"last": "Last"
}
}
};
var features = {
"autoWidth": false,
"deferRender": false,
"info": true,
"jQueryUI": false,
"lengthChange": true,
"ordering": true,
"paging": true,
"processing": true,
"scrollX": false,
"scrollY": false,
"searching": true,
"stateSave": false,
"delay": 0,
};
var options = {
"displayStart": 0,
"lengthMenu": [10, 25, 50, 100],
"orderClasses": true,
"order": [[0,"asc"]],
"orderMulti": true,
"pageLength": 50,
"pagingType": "full_numbers",
"scrollCollapse": false,
"searchDelay": 0,
"stateDuration": 7200,
"stripeClasses": [""],
"responsive": true,};
var ajax = {
"serverSide": false,
"data": [{ /*data for the table*/
};
setTimeout(function() {
var columns = {
"columns": [
{
"contentPadding": "",
"defaultContent": "",
"name": "",
"orderable": false,
"searchable": false,
"title": "<input type='checkbox' name='multiselect_checkall' class='multiselect_checkall' />",
"visible": true,
"className": "row-select",
"width": "",
"data": null,
"render": function(data, type, row, meta) {
var checkbox = "<input type='checkbox' name='multiselect_checkbox' value='" + first + "' class='multiselect_checkbox' />";
var output = "";
var startHtml = "";
var endHtml = "";
var attributes = "";
attributes += 'name="multiselect_checkbox check" ';
attributes += 'class="multiselect_checkbox" ';
var first;
if (row.hasOwnProperty('id') && typeof('id') !== 'function') {
first = row['id'];
}
if ("" != attributes) {
var custom = "";
custom += startHtml;
custom += "<input type='checkbox' value='";
custom += first;
custom += "'";
custom += attributes;
custom += "/>"
custom += endHtml;
return custom;
}
output += startHtml;
output += checkbox;
output += endHtml;
return output;
},
},
{
"contentPadding": "",
"defaultContent": "",
"name": "",
"orderable": true,
"searchable": true,
"title": "Name",
"visible": true,
"className": "row-name",
"width": "",
"data": "name",
},
{
"contentPadding": "",
"defaultContent": "",
"name": "",
"orderable": true,
"searchable": true,
"title": "Sex",
"visible": true,
"className": "row-sex",
"width": "",
"data": "sex",
},
{
"contentPadding": "",
"defaultContent": "",
"name": "",
"orderable": true,
"searchable": true,
"title": "Prio",
"visible": true,
"className": "row-priority",
"width": "",
"data": "priority",
},
{
"contentPadding": "",
"defaultContent": "",
"name": "",
"orderable": true,
"searchable": true,
"title": "Role",
"visible": true,
"className": "",
"width": "",
"data": "role",
},
{
"contentPadding": "",
"defaultContent": "",
"name": "",
"orderable": true,
"searchable": true,
"title": "(D)",
"visible": true,
"className": "row-date",
"width": "",
"data": "bday",
},
{
"contentPadding": "",
"defaultContent": "",
"name": "",
"orderable": true,
"searchable": true,
"title": "(M)",
"visible": true,
"className": "row-month",
"width": "",
"data": "bmonth",
},
{
"contentPadding": "",
"defaultContent": "",
"name": "",
"orderable": true,
"searchable": true,
"title": "(Y)",
"visible": true,
"className": "row-year",
"width": "",
"data": "byear",
},
{
"contentPadding": "",
"defaultContent": "",
"name": "",
"orderable": true,
"searchable": true,
"title": "Works",
"visible": true,
"className": "",
"width": "",
"data": "works",
},
{
"contentPadding": "",
"defaultContent": "",
"name": "",
"orderable": false,
"searchable": false,
"title": "Actions",
"visible": true,
"className": "row-buttons",
"width": "",
"data": "",
"render": function(data, type, row, meta) {
var actionsString = "";
var routeParameters, attributes, visibleFlag, roleFlag;
routeParameters = new Array();
attributes = "";
visibleFlag = true;
roleFlag = true;
roleFlag = false;
roleFlag = true;
if (true == visibleFlag && true == roleFlag) {
routeParameters["id"] = row.id;
var route = Routing.generate("artist_show", routeParameters);
attributes += 'rel="tooltip" ';
attributes += 'title="Show" ';
attributes += 'class="btn btn-info btn-sm btn-icon icon-left" ';
attributes += 'role="button" ';
var url = "<a ";
url += 'href="' + route + '" ';
url += attributes;
url += ">";
url += '<i class="entypo-info"></i> Show';
url += "</a>";
actionsString += url;
}
routeParameters = new Array();
attributes = "";
visibleFlag = true;
roleFlag = true;
roleFlag = false;
roleFlag = true;
if (true == visibleFlag && true == roleFlag) {
routeParameters["id"] = row.id;
var route = Routing.generate("artist_edit", routeParameters);
attributes += 'rel="tooltip" ';
attributes += 'title="Edit" ';
attributes += 'class="btn btn-default btn-sm btn-icon icon-left" ';
attributes += 'role="button" ';
var url = "<a ";
url += 'href="' + route + '" ';
url += attributes;
url += 'onclick="' + "return confirm('Are you sure?')" + '" ';
url += ">";
url += '<i class="entypo-pencil"></i> Edit';
url += "</a>";
actionsString += url;
}
return actionsString;
},
},
]
};
$.extend(defaults, features);
$.extend(defaults, options);
$.extend(defaults, ajax);
$.extend(defaults, columns);
if ( $.fn.dataTable.isDataTable( selector ) ) {
} else {
var oTable = $(selector).DataTable(defaults);
}
var dt_wrapper = $("#artist_datatable" + "_wrapper");
dt_wrapper.find(".dataTables_scrollFootInner").append("\x0A");
dt_wrapper.find(".multiselect_checkall").click(function(event) {
var that = this;
dt_wrapper.find("input.multiselect_checkbox:checkbox").each(function() {
this.checked = that.checked;
});
});
dt_wrapper.find(".multiselect_action_click").on('click', function(event) {
var length = dt_wrapper.find("input.multiselect_checkbox:checkbox:checked").length;
event.preventDefault();
if (length > 0) {
if (!confirm( "Are you sure?" )) {
return;
}
$.ajax({
url: $(this).attr("href"),
type: "POST",
cache: false,
data: {
'data': $("input:checkbox:checked.multiselect_checkbox", oTable.rows().nodes()).serializeArray()
},
success: function(msg) {
oTable.draw();
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
console.log(XMLHttpRequest + ' ' + textStatus + ' ' +errorThrown);
}
})
} else {
alert("You need to select at least one element.");
}
});
}, features.delay);
});
CSS:
table.dataTable{table-layout: fixed !important}
.row-name[style]{width: 18% !important}
.row-select{width: 5% !important;}
.row-sex[style],.row-priority[style],.row-date[style],.row-month[style]
{width: 5% !important;}
.row-year[style]{width: 6% !important;}
.row-buttons{width: 13%}
.row-owner, .row-spe{width:5% !important;}
.row-status{width: 5.5%;}
.row-sequence[style],.row-cat[style]{width:4% !important;}
.row-uid[style]{width: 12% !important;}
FYI: This is a symfony app and I am using SgDatatablebundle (https://github.com/stwe/DatatablesBundle ) to generate the datatable. Thanks in advance. Screenshort is attached with the sidebar open so that you can understand my problem. Look at the checkboxes (if you are almost blind like me and have trouble finding the misalignment! :p )

i fixed it using this
$('.sidebar-toggle').click(function(){
$('.dataTables_scrollHeadInner').css('width','100%');
$('.table').css('width','100%');
setTimeout(function(){
datatable.columns.adjust().draw()}
,300);
});
set your timeout according to the time taken by sidebar to close and open

Related

How to show jQuery Datatable error in a bootstrap alert-warning div rather than the alert box

I am working on an ASP.NET Core 2.1 website and I am using Datatables.net to display my record lists retrieved from a backend API.
This issue I am trying to resolve is that, whenever an error occurs while retrieving the data from the backend API, I want the error message to appear in a Bootstrap alert-error DIV on the same page as the datatable.
I have looked at https://datatables.net/forums/discussion/30033/override-default-ajax-error-behavior and Enable datatable warning alert but I am not strong in javascript so I am having some difficulty determining how to implement this feature.
Currently, I have the datatable set up in my cshtml page as follows;
<script>
jQuery(document).ready(function ($) {
var table = $("#sitelist").DataTable({
"processing": true,
"serverSide": true,
"filter": true,
"orderMulti": false,
"ajax": {
"url": "/Sites/LoadData",
"type": "POST",
"datatype": "json"
},
"columnDefs": [
{ "orderable": false, "targets": 6 },
{ "className": "text-center", "targets": [4, 5] },
{
"targets": [4, 5],
"createdCell": function(td, cellData, rowData, row, col) {
if (cellData) {
$(td).html('<i class="far fa-check-circle text-primary""></i>');
} else {
$(td).html('<i class="far fa-times-circle text-danger""></i>');
}
}
}
],
"columns": [
{ "data": "Id", "name": "Id", "autoWidth": true, "defaultContent": "" },
{ "data": "SiteName", "name": "SiteName", "autoWidth": true, "defaultContent": "" },
{ "data": "CompanyId", "name": "CompanyId", "autoWidth": true, "defaultContent": "" },
{ "data": "CompanyName", "name": "CompanyName", "autoWidth": true, "defaultContent": "" },
{ "data": "IsAdminSite", "name": "IsAdminSite", "autoWidth": true, "defaultContent": "" },
{ "data": "IsEnabled", "name": "IsEnabled", "autoWidth": true, "defaultContent": "" },
{
"render": function (data, type, full, meta) { return `<i class="far fa-edit text-primary" title="Edit">`; }
}
],
// From StackOverflow http://stackoverflow.com/a/33377633/1988326 - hides pagination if only 1 page
"preDrawCallback": function (settings) {
var api = new $.fn.dataTable.Api(settings);
var pagination = $(this)
.closest('.dataTables_wrapper')
.find('.dataTables_paginate');
pagination.toggle(api.page.info().pages > 1);
}
});
});
</script>
And here is the loaddata action in my SitesController class;
public async Task<IActionResult> LoadData()
{
try
{
await SetCurrentUser();
ViewData["Role"] = _currentRole;
var draw = HttpContext.Request.Form["draw"].FirstOrDefault();
var start = Request.Form["start"].FirstOrDefault();
var length = Request.Form["length"].FirstOrDefault();
var sortColumn = Request.Form["columns[" + Request.Form["order[0][column]"].FirstOrDefault() + "][name]"].FirstOrDefault();
var sortColumnDirection = Request.Form["order[0][dir]"].FirstOrDefault();
var searchValue = Request.Form["search[value]"].FirstOrDefault();
var pageSize = length != null ? Convert.ToInt32(length) : 0;
var skip = start != null ? Convert.ToInt32(start) : 0;
var request = new SitesGetListRequest
{
OrderBy = SetOrderBy(sortColumn, sortColumnDirection),
Filter = SetFilter(searchValue),
PageNumber = (skip / pageSize) + 1,
PageSize = pageSize
};
var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;
var endpoint = $"api/companies/{SetCompanyId()}/sites/filtered";
var siteData = await _client.GetSiteListAsync(request, endpoint, token);
if (siteData.Sites != null)
{
return Json(new
{
draw,
recordsFiltered = siteData.Paging.TotalCount,
recordsTotal = siteData.Paging.TotalCount,
data = siteData.Sites.ToList()
});
}
//TODO: Find a way to pass error to a Bootstrap alert-warning DIV rather than the jQuery (javascript) alert box
var errorMessage = $"Http Status Code: {siteData.StatusCode} - {siteData.ErrorMessages.FirstOrDefault()}";
return Json(new
{
data = "",
error = errorMessage
});
}
catch (Exception ex)
{
const string message = "An exception has occurred trying to get the list of Site records.";
_logger.LogError(ex, message);
throw;
}
}
As it stands right now, If an error exists in the object returned from the API call, I pass a message to the error property in the returned json and it shows up as an javascript alert popup box on my cshtml page and when I click OK, the datatable displays "No records found", as shown in the images below;
and...
What I want is for the error message to display in a bootstrap alert-danger div at the top of the cshtml page. I so not want the alert popup to appear and I still want the datatable to show "No records found".
I think that what I am looking for is described on Enable datatable warning alert...
Disable the alert popup by using
$.fn.dataTable.ext.errMode = 'none';
And pass the error message to the BootStrap div using
$('#example')
.on( 'error.dt', function ( e, settings, techNote, message ) {
console.log( 'An error has been reported by DataTables: ', message );
} )
.DataTable();
but instead of
console.log( 'An error has been reported by DataTables: ', message );
use something like
$("#error").html(MY ERROR MESSAGE HERE);
and assign id="error" to the bootstrap div.
But, I am having trouble figuring out how to trigger the Ajax call from my loaddata method in the SitesController and also how to correctly add the error event to the beginning of my datatable script.
Before I burn more time trying to work this out, I thought I would put this on SO and see if anyone with javascrit/jquery experience can provide some guidance.
You can add the error property to the ajax call. Probably the best will be to use fnServerData.
jQuery(document).ready(function ($) {
var table = $("#sitelist").DataTable({
"processing": true,
"serverSide": true,
"filter": true,
"orderMulti": false,
"sAjaxSource": "/Sites/LoadData",
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax({
"dataType": 'json',
"type": "GET",
"url": sSource,
"data": aoData,
"cache": false,
"success": function (data) {
fnCallback(data);
},
"error": function(error){
$("#error").html(error);
}
});
},
"columnDefs": [
{ "orderable": false, "targets": 6 },
{ "className": "text-center", "targets": [4, 5] },
{
"targets": [4, 5],
"createdCell": function(td, cellData, rowData, row, col) {
if (cellData) {
$(td).html('<i class="far fa-check-circle text-primary""></i>');
} else {
$(td).html('<i class="far fa-times-circle text-danger""></i>');
}
}
}
],
"columns": [
{ "data": "Id", "name": "Id", "autoWidth": true, "defaultContent": "" },
{ "data": "SiteName", "name": "SiteName", "autoWidth": true, "defaultContent": "" },
{ "data": "CompanyId", "name": "CompanyId", "autoWidth": true, "defaultContent": "" },
{ "data": "CompanyName", "name": "CompanyName", "autoWidth": true, "defaultContent": "" },
{ "data": "IsAdminSite", "name": "IsAdminSite", "autoWidth": true, "defaultContent": "" },
{ "data": "IsEnabled", "name": "IsEnabled", "autoWidth": true, "defaultContent": "" },
{
"render": function (data, type, full, meta) { return `<i class="far fa-edit text-primary" title="Edit">`; }
}
],
// From StackOverflow http://stackoverflow.com/a/33377633/1988326 - hides pagination if only 1 page
"preDrawCallback": function (settings) {
var api = new $.fn.dataTable.Api(settings);
var pagination = $(this)
.closest('.dataTables_wrapper')
.find('.dataTables_paginate');
pagination.toggle(api.page.info().pages > 1);
}
});
});
</script>

error 500 on jquery datatables search

i created a table with jquery datatables. when I want to filter my table with search bar, the browser gives me an alert DataTables warning: table id=grid - Ajax error. For more information about this error, please see http://datatables.net/tn/7.
this is my code :
$("#grid").dataTable({
"processing": true, // control the processing indicator.
"serverSide": true, // recommended to use serverSide when data is more than 10000 rows for performance reasons
"info": true, // control table information display field
"stateSave": true, //restore table state on page reload,
"searching": true,
"language": {
"url": "/translate/datatables.fa-IR.json"
},
"lengthMenu": [[10, 20, 50, -1], [10, 20, 50, "All"]], // use the first inner array as the page length values and the second inner array as the displayed options
"ajax": {
"url": serviceBase + "/Auth/Admin/SearchOrders2/",
"type": "GET",
'beforeSend': function (xhr) {
xhr.setRequestHeader("Authorization", "Bearer " + localStorageService.get("authorizationData").token);
}
},
"columns": [
{ "data": "customerContact", "orderable": true },
{ "data": "isDone", "orderable": true },
{
"mRender":
function (data, type, row) {
var xxx = $scope.name1 = $filter("jalaliDateFromNow")(row["createdDate"]);
return "<span>" + $filter("jalaliDateFromNow")(row["orderCreationTime"]); +'</span>';
}, "orderable": true
},
{ "data": "totalPrice", "orderable": true },
{ "data": "count", "orderable": true },
{ "data": "description", "orderable": true },
{
"mRender": function (data, type, row) {
return '<button class="btn btn-sm btn-circle green tooltips" disabled="disabled"><i class="fa fa-check"></i><span>جزئیات</span></button>'
},
"orderable": false
}
],
"order": [[0, "desc"]]
});
which part of my code is wrong?

Datatables dynamically change on row but data object not change ajax

we coding a quotation form for our company and want to add products a datatable and changing value on it. After change data we send to controller but they same the first time. Here is datatable structure.
var selectedProduct = $('#selectedproduct').DataTable({
"columns": [
{
"orderable": false,
"data": "IsConfirm",
},
{ "orderable": false, "data": "Product.Id" },
{ "orderable": false, "data": "Product.Name" },
{ "orderable": false, "data": "Product.Description" },
{
"orderable": false,
"data": "Quantity",
"render": function (data, type, full, meta) {
return '<td width="100px"><input class="touchspinquantity" type="text" value="' + data + '" name="quantity"></td>';
}
},
{ "orderable": false, "data": "Product.SalePrice" },
{
"orderable": false,
"data": "Discount",
"render": function (data, type, full, meta) {
return '<td width="100px"><input class="touchspindiscount" type="text" value="' + data + '" name="discount"></td>';
}
},
{ "orderable": false, "data": "Product.Currency" },
{ "orderable": false, "data": null, "defaultContent": '' },
{
"orderable": false,
"data": null,
"defaultContent": '<button id="deleteproduct" class="btn btn-warning btn-circle" type="button"><i class="fa fa-times"></i></button>'
},
],
"createdRow": function (row, data, index) {
if (data.IsConfirm) {
$('td', row).eq(0).html('<input type="checkbox" checked class="i-checks" name="input[]">');
}
else {
$('td', row).eq(0).html('<input type="checkbox" class="i-checks" name="input[]">');
}
},
"searching": false,
"paging": false,
"bInfo": false,
"ordering": false
});
Here is how to get data
var datat = table.fnGetData();
You may need to redraw the datatable after the updation
selectedProduct.draw();
I solved problem but maybe that's not good way.
Here is the solve
var rows = table.fnGetNodes();
var arr = [[]];
for (var i = 0; i < rows.length; i++) {
var detaildata = [];
var cells = rows[i].cells;
detaildata[0] = cells[0].childNodes["0"].checked;
detaildata[1] = cells[1].innerText;
detaildata[2] = cells[2].innerText;
detaildata[3] = cells[3].innerText;
detaildata[4] = cells[4].firstChild.childNodes[1].value;
detaildata[5] = cells[5].innerText;
detaildata[6] = cells[6].firstChild.childNodes[1].value;
detaildata[7] = cells[7].innerText;
detaildata[8] = cells[8].innerText;
arr[[i]] = detaildata;
//var select = cells[0].children[0].value;
//if (cells[0].children[0].checked) {
// select = cells[0].children[0].value;
//} else {
// select = 'off';
//}
}

internet explorer select dropdown collapse

i have select dropdown which picks no. of pages to be shown as jquery pagination. everything is fine but when it comes to ie. select dropdown collapses.see image.
i also refered link
but it seems it will not work for me.I am doubtful that is it ie default behaviour and can't do much....
<script type="text/javascript">
$(document).ready(function() {
var url="${pageContext.request.contextPath}/aaa/aaa/aaa";
url+="?fromDate=${fromDate}";
url+="&toDate=${toDate}";
url+="&callType=${callType}";
url+="&fullListSize=0";
var table = $('#call_history_detail').DataTable({
"preDrawCallback": function( settings ) {
$("#searchTable").val("");
$('body').modalProgress("show");
},
"drawCallback": function( settings ) {
wordWrap("userName", 80, 2);
$('body').modalProgress("hide");
},
"processing": true,
"serverSide": true,
"searching": false,
//"ajax": url,
"ajax": {
"contentType": "application/json",
"url": url,
"data": function ( d ) {
var drawValue = d.draw;
var length = d.length;
var start = d.start;
var sortCol = d.order[0].column;
var sortType = d.order[0].dir;
return "draw=" + drawValue + "&length=" + length + "&start=" + start + "&sortCol=" + sortCol + "&sortType=" + sortType;
}
},
"oLanguage": {
"sLengthMenu": "Show _MENU_ entries. <img src='${pageContext.request.contextPath}/img/ico_info.png' class='tt'" +
"title='The search function will only search the page you are currently viewing. To do a more expansive search, increase the entries per page. Increasing the entries per page can increase load time.' />"
},
"lengthMenu": [ [25, 50, 100, 500, 1000, 5000], [25, 50, 100, 500, 1000, 5000] ],
"columns": [
{ "name": "userName" },
{ "name": "callType"},
{ "name": "date" },
{ "name": "time" },
{ "name": "from" },
{ "name": "to" },
{ "name": "cost", "width": "10%" },
{ "name": "duration", "width": "10%" }
],
"columnDefs": [
{
"class": "userName",
"data": "userName",
"defaultContent": "",
"targets": 0
},
{
"class": "callType",
"data": "callType",
"defaultContent": "",
"targets": 1
},
{
"class": "date-time",
"data": "timeStart",
"render": function (data) {
return getShortDate(data);
},
"defaultContent": "",
"targets": 2
},
{
"class": "date-time",
"data": "timeStart",
"render": function (data) {
return getTimeString(data);
},
"defaultContent": "",
"targets": 3
},
{
"class": 'number',
"data": "origNumber",
"defaultContent": "",
"orderable": true,
"targets": 4
},
{
"class": 'number',
"data": "destNumber",
"defaultContent": "",
"orderable": true,
"targets": 5
},
{
"class": 'cost',
"data": "totalAmount",
"render": function (data) {
return "$"+data.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,');
},
"defaultContent": "",
"targets": 6
},
{
"class": 'duration',
"data": "callDuration",
"defaultContent": "00:00:00",
"orderable": false,
"targets": 7
}
],
"order": [[ 2, "desc" ]]
});
$('#backToSummary').click(function(e){
e.preventDefault();
$('form#call-history-options').submit();
});
});</script>
Add this to the css div z-index: value;

Row check box is not working in jQuery datatable

I am using a jQuery datatable with checkbox column for select checked rows value in button click event. Please see my below image.
I use this code for getting check rows
var checkedRows = dtTable._('tr.checked', { "filter": "applied" });
My problem is when i click the header row check box it's works fine. But it's shows null
in single row check box click. I am clueless.
Edit
firebug
JQuery
var dtTable = null;
var ajaxUrl = "";
$(document).ready(function () {
GetCustomerAcceptence();
$("#btnReceived").click(function () {
var checkedRows = dtTable._('tr.checked', { "filter": "applied" });
if (checkedRows == null) {
alert("checkedRows is null.");
}
else {
alert("checkedRows is not null. Value : " + checkedRows[0][1]);
}
});
function GetCustomerAcceptence() {
/* Clear datatable before reload. */
ClearDataTable();
var elementName = "";
ajaxUrl = "";
elementName = "#tblCustomerAcceptence";
ajaxUrl = '#Url.Action("GetCustomerAcceptenceOrders", "Dispatch")';
dtTable = $(elementName).dataTable({
bProcessing: false,
bLengthChange: false,
bInfo: false,
bFilter: false,
bPaginate: false,
sAjaxSource: ajaxUrl,
aoColumns: [
{
"sClass": "checkbox-column",
bSortable: false,
"mRender": function (data, type, full) {
return '<input type="checkbox" onclick="check(this)" class="icheck-input">';
}
},
{ sTitle: "Id", bSortable: false, bVisible: false },
{ sTitle: "Number", bSortable: false, },
{ sTitle: "Description", bFilterable: true, bSortable: false, },
{ sTitle: "PoBox Number", bSortable: false, },
{ sTitle: "Owner", bSortable: false, },
{ sTitle: "Physical Weight", bSortable: false, },
{ sTitle: "Vol.Weight", bSortable: false, },
{ sTitle: "Last Status", bSortable: false, },
{ sTitle: "Zone", bSortable: false, },
],
"fnServerParams": function (aoData) {
aoData.push(
{ "name": "MasterAWB", "value": "0" },
{ "name": "PoboxNumber", "value": "0" },
{ "name": "TypeofGoods", "value": 0 },
{ "name": "Provider", "value": 0 },
{ "name": "DateFrom", "value": "0" },
{ "name": "DateTo", "value": "0" },
{ "name": "Zone", "value": 0 },
{ "name": "BagNumber", "value": "0" }
);
},
});
}
function ClearDataTable() {
if (dtTable != null) {
dtTable.dataTable().fnClearTable();
dtTable.dataTable().fnDestroy();
}
}
});
I am really sorry to say that there is a mistake in check box column. I need to place check function in my webpage to fire the check box checked event.
/* checkbox in table */
function check(e) {
if ($(e).parent('td').parent('tr').hasClass('checked')) {
$(e).parent('td').parent('tr').parent('tbody').parent('table').children('thead').find('th:first').children('div').removeClass('checked');
$(e).parent('td').parent('tr').removeClass('checked');
}
else {
$(e).parent('td').parent('tr').addClass('checked');
dtTable.fnDraw();
}
}
/* end */

Categories

Resources