How to disable a draw function on search
How to disable a draw function on search
atataylor
Posts: 35Questions: 7Answers: 0
I am using the following code to place a page number next to a headline, using the data from the pagination. The headline is league. So, when on page 2 the headline reads league 2 and so on. It is working great. I am looking for a way to hide the added number when the search box is used because the number is no longer relevant as the table repopulates when the new data is displayed.
Not sure if what I am trying to do is possible or not, so any help would be welcome.
table.on( 'draw', function () {
var info = table.page.info();
$('#tableInfo').html(
'Sales League '+(info.page+1));
} );
Replies
You could also check the number of rows in your
info
variable. IfrecordsDisplay
isn't equal torecordsTotal
, then you know the table is being filtered.Colin
Thanks Colin I will work on that idea
Following Colins advice and doing some research I have added the following code below the initial code posted earlier in the discussion. But it does not work, am I on the right track anyone?
I think you missed the point of my message, I meant something like:
Colin
Hi Colin Thanks, you are right I did miss the point of your message thanks for persevering with me.
I eventually came up with this:
But it feels a bit hackney as it involves splitting the words from the numbers in html and putting them in separate h tags. Then aligning them in a div with css.
So, your solution is much more elegant and works great so I will use your code. Thanks for your help and advice.