|
|
|
@ -29,21 +29,22 @@
|
|
|
|
|
* For ex: $(this) means jQuery(this) and S.fn.x means jQuery.fn.x
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$.fn.datatables_extended_serverside_paging = function (settings , url, dataFilter,
|
|
|
|
|
$.fn.datatables_extended_serverside_paging = function (settings, url, dataFilter,
|
|
|
|
|
columns, fnCreatedRow, fnDrawCallback, options) {
|
|
|
|
|
var elem = $(this);
|
|
|
|
|
|
|
|
|
|
// EMM related function
|
|
|
|
|
if (InitiateViewOption) {
|
|
|
|
|
$(document).on('click','.viewEnabledIcon',InitiateViewOption);
|
|
|
|
|
$(document).on('click', '.viewEnabledIcon', InitiateViewOption);
|
|
|
|
|
}
|
|
|
|
|
//--- End of EMM related codes
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Work around for accessing settings params inside datatable functions
|
|
|
|
|
*/
|
|
|
|
|
if(settings != null && settings.sorting != null && settings.sorting != undefined && settings.sorting){
|
|
|
|
|
if (settings != null && settings.sorting != null && settings.sorting != undefined && settings.sorting) {
|
|
|
|
|
elem.addClass('sorting-enabled');
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
elem.addClass('sorting-disabled');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -53,22 +54,22 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
|
|
|
|
|
//--- End of EMM related codes
|
|
|
|
|
|
|
|
|
|
$(elem).DataTable(
|
|
|
|
|
$.extend({},{
|
|
|
|
|
$.extend({}, {
|
|
|
|
|
serverSide: true,
|
|
|
|
|
processing: false,
|
|
|
|
|
searching: true,
|
|
|
|
|
ordering: false,
|
|
|
|
|
ordering: false,
|
|
|
|
|
filter: false,
|
|
|
|
|
bSortCellsTop: true,
|
|
|
|
|
ajax : {
|
|
|
|
|
ajax: {
|
|
|
|
|
url: context + "/api/data-tables/invoker",
|
|
|
|
|
data : function (params) {
|
|
|
|
|
data: function (params) {
|
|
|
|
|
var i;
|
|
|
|
|
var searchParams = {};
|
|
|
|
|
for (i = 0; i < params.columns.length; i++) {
|
|
|
|
|
searchParams[params.columns[i].data] = encodeURIComponent(params.columns[i].search.value);
|
|
|
|
|
}
|
|
|
|
|
if(options) {
|
|
|
|
|
if (options) {
|
|
|
|
|
searchParams[options.searchKey] = encodeURIComponent(params.search.value);
|
|
|
|
|
}
|
|
|
|
|
params.filter = JSON.stringify(searchParams);
|
|
|
|
@ -87,14 +88,14 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
|
|
|
|
|
columns: columns,
|
|
|
|
|
responsive: false,
|
|
|
|
|
autoWidth: false,
|
|
|
|
|
dom:'<"dataTablesTop"' +
|
|
|
|
|
'f' +
|
|
|
|
|
'<"dataTables_toolbar">' +
|
|
|
|
|
'>' +
|
|
|
|
|
'rt' +
|
|
|
|
|
'<"dataTablesBottom"' +
|
|
|
|
|
'lip' +
|
|
|
|
|
'>',
|
|
|
|
|
dom: '<"dataTablesTop"' +
|
|
|
|
|
'f' +
|
|
|
|
|
'<"dataTables_toolbar">' +
|
|
|
|
|
'>' +
|
|
|
|
|
'rt' +
|
|
|
|
|
'<"dataTablesBottom"' +
|
|
|
|
|
'lip' +
|
|
|
|
|
'>',
|
|
|
|
|
language: {
|
|
|
|
|
searchPlaceholder: options.placeholder,
|
|
|
|
|
search: ''
|
|
|
|
@ -119,7 +120,7 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
column
|
|
|
|
|
//.search(val ? '^' + val + '$' : '', true, false)
|
|
|
|
|
//.search(val ? '^' + val + '$' : '', true, false)
|
|
|
|
|
.search(val ? val : '', true, false)
|
|
|
|
|
.draw();
|
|
|
|
|
|
|
|
|
@ -193,24 +194,42 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
|
|
|
|
|
/**
|
|
|
|
|
* create sorting dropdown menu for list table advance operations
|
|
|
|
|
*/
|
|
|
|
|
var dropdownmenu = $('<ul class="dropdown-menu arrow arrow-top-right dark sort-list add-margin-top-2x"><li class="dropdown-header">Sort by</li></ul>');
|
|
|
|
|
$('.sort-row th', elem).each(function () {
|
|
|
|
|
if (!$(this).hasClass('no-sort')) {
|
|
|
|
|
dropdownmenu.append('<li><a href="#' + $(this).html() + '" data-column="' + $(this).index() + '">' + $(this).html() + '</a></li>');
|
|
|
|
|
var table = this;
|
|
|
|
|
if (table.hasClass('sorting-enabled')) {
|
|
|
|
|
var dropdownmenu = $('<ul class="dropdown-menu arrow arrow-top-right dark sort-list add-margin-top-2x"><li class="dropdown-header">Sort by</li></ul>');
|
|
|
|
|
$('.sort-row th', elem).each(function () {
|
|
|
|
|
if (!$(this).hasClass('no-sort')) {
|
|
|
|
|
dropdownmenu.append('<li><a href="#' + $(this).html() + '" data-column="' + $(this).index() + '">' + $(this).html() + '</a></li>');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getAdvanceToolBar() {
|
|
|
|
|
if (table.hasClass('sorting-enabled')) {
|
|
|
|
|
return '<ul class="nav nav-pills navbar-right remove-margin" role="tablist">' +
|
|
|
|
|
'<li><button data-click-event="toggle-selectable" class="btn btn-default btn-primary select-enable-btn">Select</li>' +
|
|
|
|
|
'<li><button data-click-event="toggle-selected" id="dt-select-all" class="btn btn-default btn-primary disabled">Select All</li>' +
|
|
|
|
|
'<li><button data-click-event="toggle-list-view" data-view="grid" class="btn btn-default"><i class="fw fw-grid"></i></button></li>' +
|
|
|
|
|
'<li><button data-click-event="toggle-list-view" data-view="list" class="btn btn-default"><i class="fw fw-list"></i></button></li>' +
|
|
|
|
|
'<li><button class="btn btn-default" data-toggle="dropdown"><i class="fw fw-sort"></i></button>' + dropdownmenu[0].outerHTML + '</li>' +
|
|
|
|
|
'</ul>'
|
|
|
|
|
} else {
|
|
|
|
|
return '<ul class="nav nav-pills navbar-right remove-margin" role="tablist">' +
|
|
|
|
|
'<li><button data-click-event="toggle-selectable" class="btn btn-default btn-primary select-enable-btn">Select</li>' +
|
|
|
|
|
'<li><button data-click-event="toggle-selected" id="dt-select-all" class="btn btn-default btn-primary disabled">Select All</li>' +
|
|
|
|
|
'<li><button data-click-event="toggle-list-view" data-view="grid" class="btn btn-default"><i class="fw fw-grid"></i></button></li>' +
|
|
|
|
|
'<li><button data-click-event="toggle-list-view" data-view="list" class="btn btn-default"><i class="fw fw-list"></i></button></li>' +
|
|
|
|
|
'</ul>'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* append advance operations to list table toolbar
|
|
|
|
|
*/
|
|
|
|
|
$('.dataTable.list-table').closest('.dataTables_wrapper').find('.dataTablesTop .dataTables_toolbar').html('' +
|
|
|
|
|
'<ul class="nav nav-pills navbar-right remove-margin" role="tablist">' +
|
|
|
|
|
'<li><button data-click-event="toggle-selectable" class="btn btn-default btn-primary select-enable-btn">Select</li>' +
|
|
|
|
|
'<li><button data-click-event="toggle-selected" id="dt-select-all" class="btn btn-default btn-primary disabled">Select All</li>' +
|
|
|
|
|
'<li><button data-click-event="toggle-list-view" data-view="grid" class="btn btn-default"><i class="fw fw-grid"></i></button></li>' +
|
|
|
|
|
'<li><button data-click-event="toggle-list-view" data-view="list" class="btn btn-default"><i class="fw fw-list"></i></button></li>' +
|
|
|
|
|
'<li><button class="btn btn-default" data-toggle="dropdown"><i class="fw fw-sort"></i></button>' + dropdownmenu[0].outerHTML + '</li>' +
|
|
|
|
|
'</ul>'
|
|
|
|
|
$('.dataTable.list-table').closest('.dataTables_wrapper').find('.dataTablesTop .dataTables_toolbar').html(
|
|
|
|
|
getAdvanceToolBar()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -248,14 +267,14 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
|
|
|
|
|
$(button).addClass("active").html('Cancel');
|
|
|
|
|
$(button).parent().next().children("button").removeClass("disabled");
|
|
|
|
|
// EMM related code
|
|
|
|
|
$(document).off('click','.viewEnabledIcon');
|
|
|
|
|
$(document).off('click', '.viewEnabledIcon');
|
|
|
|
|
//--- End of EMM related codes
|
|
|
|
|
} else if ($(button).html() == 'Cancel') {
|
|
|
|
|
thisTable.removeClass("table-selectable");
|
|
|
|
|
$(button).addClass("active").html('Select');
|
|
|
|
|
$(button).parent().next().children().addClass("disabled");
|
|
|
|
|
// EMM related function
|
|
|
|
|
$(document).on('click','.viewEnabledIcon',InitiateViewOption);
|
|
|
|
|
$(document).on('click', '.viewEnabledIcon', InitiateViewOption);
|
|
|
|
|
//--- End of EMM related codes
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -314,6 +333,6 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},settings)
|
|
|
|
|
}, settings)
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|