How to disable Drag and Drop on fixed columns in datatable ??
How to disable Drag and Drop on fixed columns in datatable ??
HI Allan,
i am new to datatable , i am using ColReorder with FixedColumn plugin. bellow are my issues.
a) able to drop column onto fixed columns this should not happen how can i handle this??
b) able to reordering fixed columns. it should not happen how can i prevent it??
bellow is my code.
in js:
function displayQGData(){
objQG.bIsSKPD = StarsUtility.GetData("isstandardsskipped", {"iGradeID" : objQG.gradeBased ? $("#selQGGrade").val() : -1 , "lAssessmentID" : $("#SC_ASSESSMENT_ID").val()}, true);
var col = [];
col.push({ "mData": "SortOrder", "sWidth": "50px"});
col.push({ "mData": "ShortName", "sWidth": "60px"});
col.push({ "mData": "StandardName", "sWidth": ""});
var i = 1;
if(StarsUtility.GetSize(objQG.mpQGH) > 0){
$.each(objQG.mpQGH, function(key, objS){
col.push({"mData": "GroupItems_"+ i++, "sWidth": "150px"});
});
}else{
objQG.iNoQG = parseInt($("#no-of-groups").val());
for(var j = 0; j< objQG.iNoQG; j++){
col.push({"mData": "GroupItems_"+ i++, "sWidth": "150px"});
}
}
var table = $('#create-groups-all-in-one-table')
.dataTable({
"bDestroy":true,
"bServerSide": true,
"bProcessing": false,
"bSearchable": false,
"scrollY": "300px",
"scrollX": true,
"scrollCollapse": true,
"paging": false,
"bSortCellsTop": true,
"bAutoWidth": false,
"bInfo": true,
"bFilter":false,
"sAjaxSource": $("#SC_CONTEXT_PATH").val() + '/sc/getqgdata',
"oScroller": {
"loadingIndicator": true
},
"fnServerData": function ( sSource, aoData, fnCallback ) {
var o = CommonFunctions.StringifyData(aoData);
var arTemp = {};
if(StarsUtility.IsEmptyObject(objQG.params)) {
arTemp = getAllParams();
} else { arTemp = objQG.params ;}
o['dataparams'] = arTemp;
//console.log(">>--------------->"+JSON.stringify(o));
$.ajax( {
dataType: 'json',
contentType: "application/json;charset=UTF-8",
type: "POST",
url: sSource,
data: JSON.stringify(o),
success: function(z){
z = buildQGTableData(z);
objQG.totalRec = z.iTotalRecords;
$("#sp-no-of-que").html(objQG.totalRec);
fnCallback(z);
},
error : function (e) {}
} );
},
"fnDrawCallback": function ( oSettings ) {
if (this.fnSettings().fnRecordsDisplay() == 0) {
$('#create-groups-all-in-one-table_thead, .dataTables_length, .dataTables_info, .dataTables_paginate, #divFunction').hide();
$('.dataTables_info').parent().hide();
} else {
$('#create-groups-all-in-one-table_thead, .dataTables_length, .dataTables_info, .dataTables_paginate, #divFunction').show();
$('.dataTables_info').parent().show();
}
CommonFunctions.PageNumbers(objQG.totalRec, 'create-groups-all-in-one-table', oSettings);
$(".dataTables_info,.row-fluid").hide();
},
"oLanguage": {
"sZeroRecords": "No data available.",
"sProcessing": "
"
},
"aoColumnDefs": [
{"bSortable": false, "aTargets": objQG.arr},
{ "targets": [2], "visible": !objQG.bIsSKPD }
],
"aoColumns": col,
"aaSorting": [[0,'asc']]
} );
$("[data-toggle=popover]").popover();
new $.fn.dataTable.FixedColumns( table, {
leftColumns: 3
} );
new $.fn.dataTable.ColReorder( table );
}
in jsp i hav included bellow js:
please give some solution to fix this issues.
Answers
I had thought that there was an option to stop reordering being allowed on a column, but looking at the docs and code, that doesn't appear to be the case. So I'm afraid there is no option for that at the moment.
Allan
Hello Allan,
Thank you for replay.
actually
i was passing arguments like this new $.fn.dataTable.ColReorder( table );
so able to reorder for fixed column as in plugin default "iFixedColumns": is 0,
hence fixed column was reordering
now
issue no b) able to reordering fixed columns. this issue fixed by passing argument like this
new $.fn.dataTable.ColReorder( table, {
"iFixedColumns": 3
} );
but for fixing a) able to drop column onto fixed columns
in plugin for time being i fixed like bellow
in dataTables.colReorder.js
bellow function when reordering event is fired :
i hard coded like
if(iTo < 3){
return;
}
if TO column is less than 3 then am retuning back so its fixed. but it should be dynamic.
how will i get to know fixed column size dynamically??? so that i can include dynamically.
$.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
{
var v110 = $.fn.dataTable.Api ? true : false;
var i, iLen, j, jLen, iCols=oSettings.aoColumns.length, nTrs, oCol;
var attrMap = function ( obj, prop, mapping ) {
if ( ! obj[ prop ] ) {
return;
}