Help with adding class to row
Help with adding class to row
Hi guys, I wish you could Help me with some issue.
I'm using bootstrap and dataTables and I wish to add an error class to all row that contains the value=1 in a column named 'bajaProductoActividad'.
My table is $('#tbLstActProds')
this is my code in the draw Call back
[code]"fnDrawCallback" : function(oSettings) {
$('#tbLstActProds').find('tbody tr').click(function(e){
if ($(this).hasClass('success')) {
$(this).removeClass('success');
edh.rowIDActProdEDH = 0;
console.log(edh.rowIDActProdEDH);
} else {
$('#tbLstActProds').find('tbody tr').removeClass('success');
$(this).addClass('success');
var Id = edh.tablaProductoActividadEDH.fnGetData(this);
if(Id!=null){
edh.rowIDActProdEDH = Id['productoActividadID'];
console.log(edh.rowIDActProdEDH);
}
}
});[/code]
It's a products table, So, I'm able to add products and the table will redraw anytime I click the button and will show all products contained in a temporary object which I use as 'aData' in the table constructor.
I have to mention also, when I click a product I add the class 'success' for color it green.
so what I wanna do is everytime I click a product and color it green, and then I click the button Delete, This product won't dissapear from the table But It will get red colored with the class error but only if there is value = 1 in a hidden column. so that way I know when a product will be deleted when it's 1 and if it won't the value is 0.
Sorry for my english, Sometime I get difficulties by trying to express some issues. I hope you help me.
this is the function on the table
[code]tablaProductoActividadEDH: function(){
var responsiveHelper;
$('#tbLstActProds').dataTable().fnClearTable();
$('#tbLstActProds').dataTable().fnDestroy();
var columnDefs = [{"aTargets" : [ 0 ], "mData" : "productoNombre"},
{"aTargets" : [ 1 ], "mData" : "tonelaje"},
{"aTargets" : [ 2 ], "mData" : "piezas"},
{"aTargets" : [ 3 ], "mData" : "productoActividadID", "bVisible" : false},
{"aTargets" : [ 4 ], "mData" : "bajaProductoActividad", "bVisible" : false}];
edh.tablaProductoActividadEDH=$('#tbLstActProds').dataTable({
"bAutoWidth" : false,
"bInfo" : false,
"bSort" : false,
"sPaginationType" : "bootstrap",
"iDisplayLength" : 25,
"aLengthMenu" : [ 25, 50, 100 ],
"oLanguage" : {
"sUrl" : "js/lib/locale/dataTables.spanish.txt"
},
"sDom" : '<"top">rt<"bottom"i><"clear">',
'aaData' : edh.prodActTemp,
"aoColumnDefs" : columnDefs,
"fnPreDrawCallback" : function() {
if (!responsiveHelper) {
// responsiveHelper = new ResponsiveDatatablesHelper(tablaVar, edh.breakpointDefinition);
}
},
"fnDrawCallback" : function(oSettings) {
$('#tbLstActProds').find('tbody tr').click(function(e){
if ($(this).hasClass('success')) {
$(this).removeClass('success');
edh.rowIDActProdEDH = 0;
console.log(edh.rowIDActProdEDH);
} else {
$('#tbLstActProds').find('tbody tr').removeClass('success');
$(this).addClass('success');
var Id = edh.tablaProductoActividadEDH.fnGetData(this);
if(Id!=null){
edh.rowIDActProdEDH = Id['productoActividadID'];
console.log(edh.rowIDActProdEDH);
}
}
});
// responsiveHelper.respond();
},
"fnRowCallback" : function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
// responsiveHelper.createExpandIcon(nRow);
},
"fnInitComplete" : function() {
$('.dataTables_length').addClass('pull-left');
$('.dataTables_paginate').addClass('pull-right');
}
});
},[/code]
I'm using bootstrap and dataTables and I wish to add an error class to all row that contains the value=1 in a column named 'bajaProductoActividad'.
My table is $('#tbLstActProds')
this is my code in the draw Call back
[code]"fnDrawCallback" : function(oSettings) {
$('#tbLstActProds').find('tbody tr').click(function(e){
if ($(this).hasClass('success')) {
$(this).removeClass('success');
edh.rowIDActProdEDH = 0;
console.log(edh.rowIDActProdEDH);
} else {
$('#tbLstActProds').find('tbody tr').removeClass('success');
$(this).addClass('success');
var Id = edh.tablaProductoActividadEDH.fnGetData(this);
if(Id!=null){
edh.rowIDActProdEDH = Id['productoActividadID'];
console.log(edh.rowIDActProdEDH);
}
}
});[/code]
It's a products table, So, I'm able to add products and the table will redraw anytime I click the button and will show all products contained in a temporary object which I use as 'aData' in the table constructor.
I have to mention also, when I click a product I add the class 'success' for color it green.
so what I wanna do is everytime I click a product and color it green, and then I click the button Delete, This product won't dissapear from the table But It will get red colored with the class error but only if there is value = 1 in a hidden column. so that way I know when a product will be deleted when it's 1 and if it won't the value is 0.
Sorry for my english, Sometime I get difficulties by trying to express some issues. I hope you help me.
this is the function on the table
[code]tablaProductoActividadEDH: function(){
var responsiveHelper;
$('#tbLstActProds').dataTable().fnClearTable();
$('#tbLstActProds').dataTable().fnDestroy();
var columnDefs = [{"aTargets" : [ 0 ], "mData" : "productoNombre"},
{"aTargets" : [ 1 ], "mData" : "tonelaje"},
{"aTargets" : [ 2 ], "mData" : "piezas"},
{"aTargets" : [ 3 ], "mData" : "productoActividadID", "bVisible" : false},
{"aTargets" : [ 4 ], "mData" : "bajaProductoActividad", "bVisible" : false}];
edh.tablaProductoActividadEDH=$('#tbLstActProds').dataTable({
"bAutoWidth" : false,
"bInfo" : false,
"bSort" : false,
"sPaginationType" : "bootstrap",
"iDisplayLength" : 25,
"aLengthMenu" : [ 25, 50, 100 ],
"oLanguage" : {
"sUrl" : "js/lib/locale/dataTables.spanish.txt"
},
"sDom" : '<"top">rt<"bottom"i><"clear">',
'aaData' : edh.prodActTemp,
"aoColumnDefs" : columnDefs,
"fnPreDrawCallback" : function() {
if (!responsiveHelper) {
// responsiveHelper = new ResponsiveDatatablesHelper(tablaVar, edh.breakpointDefinition);
}
},
"fnDrawCallback" : function(oSettings) {
$('#tbLstActProds').find('tbody tr').click(function(e){
if ($(this).hasClass('success')) {
$(this).removeClass('success');
edh.rowIDActProdEDH = 0;
console.log(edh.rowIDActProdEDH);
} else {
$('#tbLstActProds').find('tbody tr').removeClass('success');
$(this).addClass('success');
var Id = edh.tablaProductoActividadEDH.fnGetData(this);
if(Id!=null){
edh.rowIDActProdEDH = Id['productoActividadID'];
console.log(edh.rowIDActProdEDH);
}
}
});
// responsiveHelper.respond();
},
"fnRowCallback" : function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
// responsiveHelper.createExpandIcon(nRow);
},
"fnInitComplete" : function() {
$('.dataTables_length').addClass('pull-left');
$('.dataTables_paginate').addClass('pull-right');
}
});
},[/code]
This discussion has been closed.