tbody first row disable sorting in datatable
tbody first row disable sorting in datatable
tariqnawaz
Posts: 5Questions: 2Answers: 0
Hi , I want to disable sorting for my first row in tbody. I have seen all possible example but it did not work for me. I am doing this from last 2 days , so any help will be appreciated. thanks in advance.
javascript
$(document).ready(function() {
var typeName ='';
var oTable = $('#table_id1').dataTable({
//"bPaginate": false,
"scrollX" : true,
"iDisplayLength": 100,
"lengthMenu": [ 100, 250, 500, 750, 1000 ],
"columnDefs": [
{
"targets": [ 0 ],
"visible": false
}
],
initComplete: function () {
this.api().columns(0).every( function () {
var column = this;
var select = $('<select id="filterSelect"></select>')
.appendTo( $('#type').empty() )
.on( 'change', function () {
var val = $(this).val();
typeName = $(this).val();
//console.log(val);
fnShowHide( typeName );
column.search( val ? '^'+val+'$' : '', true, false )
.draw();
} );
column.data().unique().sort().each( function ( d, j ) {
if(d == 'Consistent Performers - Debt funds'){
select.append( '<option selected value="'+d+'">'+d+'</option>' )
column.search( d ? '^'+d+'$' : '', true, false ).draw();
fnShowHide(d);
}else{
select.append( '<option value="'+d+'">'+d+'</option>' )
}
} );
} );
var self = this;
var api = this.api();
api.rows().eq(0).each(function(index) {
var row = api.row(index);
//alert("row"+row+"row data"+row.data());
if(index == 0){
var $row_to_persist = $(row.node());
var $clone = $row_to_persist .clone();
$(self).find('thead:last').append($clone);
$total_row.remove();
row.remove();
//$('#table_id1 thead').append($clone);
api.draw();
}
});
}
});
html
Sep-16 Rank | Mean Return | Volatility | Industry Concentration | Company Concentration | Liquidity | Superior Return Score | Debt asset Quality | Debt Liquidity | Equity Liquidity | Modified Duration | Asset Quality | CRISIL Rank Performance | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
<%=dto.getType()%> | <%=dto.getEntityName()%> | <%=dto.getSep16Rank()%> | <%=dto.getMeanReturn()%> | <%=dto.getVolatility()%> | <%=dto.getIndustryConcentration()%> | <%=dto.getCompanyConcentration()%> | <%=dto.getLiquidity()%> | <%=dto.getSuperiorReturnScore()%> | <%=dto.getDebtAssetQuality()%> | <%=dto.getDebtLiquidity()%> | <%=dto.getEquityLiquidity()%> | <%=dto.getModifiedDuration()%> | <%=dto.getAssetQuality()%> | <%=dto.getCrisilRankPerformance()%> |
This discussion has been closed.