how to hsow image in row group header or jquery rowgroup datatable

how to hsow image in row group header or jquery rowgroup datatable

farwafarwa Posts: 2Questions: 1Answers: 0

I am using jquery datatable plugin with asp.net webforms and gridview ,I want to put an image in group header with condition base on cssClass of my code is

      $(document).ready(function () {
         var table = $('#grdInspection').DataTable({
       "columnDefs": [
       { "visible": false, "targets": 2 }
     ],

"order": [[2, 'asc']],
"displayLength": 3,
"paging": false,
"ordering": false,
"info": false,
"searching": false,
"drawCallback": function (settings) {
    var api = this.api();
    var rows = api.rows({ page: 'current' }).nodes();
    var last = null;

    api.column(2, { page: 'current' }).data().each(function (group, i) {
        var element = $("#grdInspection").find('td').hasClass('blink');
        var ratingTdClass;
        var element_blue;
       // alert(element);
        if (last !== group && element == true ) {
            $(rows).eq(i).before(
                '<tr class="group"><td colspan="5">' + group + '<img src="redCircle.gif" / ></td></tr>'
                               );
            last = group;
        }
        else if (last !== group && element == false) {
            $(rows).eq(i).before(
                '<tr class="group"><td colspan="5">' + group + '<img src="greenCircle.gif"style="margin-left:5%;" / ></td></tr>'
            );

            last = group;
        }
        else if (last !== group) {
            $(rows).eq(i).before(
                '<tr class="group"><td colspan="5">' + group + '</td></tr>'
            );

            last = group;
        }
    });
}
 });

// Order by the grouping
$('#grdInspection tbody').on('click', 'tr.group', function () {
  var currentOrder = table.order()[0];
  if (currentOrder[0] === 2 && currentOrder[1] === 'asc') {
    table.order([2, 'desc']).draw();
    }
   else {
    table.order([2, 'asc']).draw();
   }
});
})

Condition not working,I want the function which read the all classes and if have cssClass "blink" then redCircle image show in Group header,if haven't cssClass "blink" then greenCircle and if have cssClass "backgroundBlue" then no image show in group header

Replies

This discussion has been closed.