Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using this and have a datatable in my page.

I am receiving values from another site pages, and according to them I should redraw table.

I am receiving BookNo value, and when table is loaded, I should open page where this BookNo is placed. (If it is placed on page 2 or 3, I should open those page).

I found this and tried to use it:

C#
jQuery.fn.dataTable.Api.register('page.jumpToData()', function (data, column) {
           var pos = this.column(column, { order: 'current' }).data().indexOf(data);

           if (pos >= 0) {
               var page = Math.floor(pos / this.page.info().length);
               this.page(page).draw(false);
           }

           return this;
        });


and:
C#
var dtApi = new $.fn.dataTable.Api("#Book_grid");
dtApi.page.jumpToData(selectedBookNo, 1);

And nothing. Its supposed to work but, no. When this tries to set var pos property, it always returns -1.

According to links, I expected to open propher page where searched BookNo are placed.

What am I missing and what I am doing wrong?

P.S
I have many things on page which works with
$.fn.dataTable.Api("#Book_grid");
and I'm sure that this exist.
With
var dtApi = $("#Book_grid").DataTable();
I got the same result.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900