1.9 Pagination - TR custom class/attributes disappear after 1st page

1.9 Pagination - TR custom class/attributes disappear after 1st page

dr3xdr3x Posts: 12Questions: 1Answers: 0

I'm applying a custom class to the TR elements in a data table with the pagination option turned on and I'm finding the class I applied is only showing up on the 1st page. So I tried a custom attribute and same thing - only on the first page. On initial apply I verified that .dataTable().fnAddData({...}) is getting called for all rows in the table and on the call is setting the element correctly.

It seems that the only class applied on the last page is the odd/even class:

First page:

<tr class="odd unread" data-ru="unread">

Last page:

<tr class="odd">

The custom class/attribute on the 1st page persist if I switch to the last page and back so it isn't something happening on the page event.

Options:

  var dtOptions = {
    "sDom": '<"top"f>rt<"modal-footer"lip><"clear">',
    "aoColumnDefs": [{
      "bSortable": false,
      "aTargets": [0]
    }],
    "bAutoWidth": false,
  };

Answers

  • dr3xdr3x Posts: 12Questions: 1Answers: 0

    Ok, have a workaround for now but it is somewhat hacky:

    1. Hook 'draw.dt' event which returns two parameters, event and data
    2. Check for whether the custom classes are missing
    3. Iterate through the tr collection, retrieving the attribute value from a new hidden column starting at data.aoData[_iDisplayStart]._aData[hiddenColumnIndex]
This discussion has been closed.