0

I need to get the first displayed row value of data-rowNum attribute when next page event if fired.

My HTML table:

<tr data-rowNum="1">Some text</tr>
<tr data-rowNum="2">Some text</tr>
<tr data-rowNum="3">Some text</tr>

Here is the code I use, but not getting the value, only an object.

$('#historico').on( 'page.dt search.dt order.dt', function () {
  alert(tabla.row( 0 ).data('rowNum'));
} );

1 Answer 1

1

You need to use row().node() to get the row TR node and to$() to convert it to jQuery object.

Argument { 'order': 'current', 'search': 'applied', 'page': 'current'} which is selector-modifier for row() API function is used to retrieve row for current page with sorting and filtering applied.

$('#historico').on( 'page.dt search.dt order.dt', function () {
    alert(
       tabla
          .row( 0, { 'order': 'current', 'search': 'applied', 'page': 'current'} )
          .node()
          .to$()
          .data('rowNum'));
});
Sign up to request clarification or add additional context in comments.

3 Comments

Thnx Gycocode! Now i can access the first row custom data! Is it possible to access the current page first element? Now it's getting the whole table first element.
@SauronZ, added more details per your suggestion.
Thnx again. You opened to me a new world of posibilities. :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.