diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.js
index 812acca6f7f..5de71a61d8a 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.js
@@ -30,6 +30,15 @@ $.fn.datatables_extended = function(settings){
}
//--- 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){
+ elem.addClass('sorting-enabled');
+ }else{
+ elem.addClass('sorting-disabled');
+ }
+
$(elem).DataTable(
$.extend({},{
bSortCellsTop: true,
@@ -132,24 +141,41 @@ $.fn.datatables_extended = function(settings){
/**
* create sorting dropdown menu for list table advance operations
*/
- var dropdownmenu = $('
');
- $('.sort-row th', elem).each(function(){
- if(!$(this).hasClass('no-sort')){
- dropdownmenu.append('' + $(this).html() + '');
- }
- });
+ var table = this;
+ if(table.hasClass('sorting-enabled')){
+ var dropdownmenu = $('');
+ $('.sort-row th', elem).each(function () {
+ if (!$(this).hasClass('no-sort')) {
+ dropdownmenu.append('' + $(this).html() + '');
+ }
+ });
+ }
+
+ function getAdvanceToolBar(){
+ if(table.hasClass('sorting-enabled')){
+ return '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '- ' + dropdownmenu[0].outerHTML + '
' +
+ '
'
+ }else{
+ return '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '
'
+ };
+ }
+
/**
* append advance operations to list table toolbar
*/
- $('.dataTable.list-table').closest('.dataTables_wrapper').find('.dataTablesTop .dataTables_toolbar').html('' +
- '' +
- '' +
- '' +
- '' +
- '' +
- '- '+dropdownmenu[0].outerHTML+'
' +
- '
'
+ $('.dataTable.list-table').closest('.dataTables_wrapper').find('.dataTablesTop .dataTables_toolbar').html(
+ getAdvanceToolBar()
);
/**
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js
index 3dc7ce83d0e..ddd23500558 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js
@@ -38,6 +38,15 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
$(document).on('click','.viewEnabledIcon',InitiateViewOption);
}
+ /*
+ * Work around for accessing settings params inside datatable functions
+ */
+ if(settings != null && settings.sorting != null && settings.sorting != undefined && settings.sorting){
+ elem.addClass('sorting-enabled');
+ }else{
+ elem.addClass('sorting-disabled');
+ }
+
var deviceType;
var ownership;