1

I have a table have 6 columns , I used datatable:

 $('#datatable2').dataTable({
                "oLanguage": { "sSearch": "Search " },
                "oSearch": { "sSearch": "<% = requestId %>" }
               });

when I use this table appear very nice but it didn't sort numbers when I add this

 $('#datatable2').dataTable({
                     "aoColumns": [
                               { "sType": "numeric-comma" },
                               null,
                               null,
                               null, null, null],

                "oLanguage": { "sSearch": "search: " },
                "oSearch": { "sSearch": "<% = requestId %>" }
               });

it sort number correctly but it appears all the rows not 10 by 10 or 50 by 50 as this pic

please help!

enter image description here

when I use this code

paging:true,
"aoColumns": [{ "sType": "numeric" }, null, null,null , null, null],

it appear gridview as enter image description here

it sort as I need but why it get number 129 in the second row ?

Note that:- My integer numbers is hyperlink

1 Answer 1

1

You have to enable pagination, so datatables know how to deal with more then page length number of rows. Parameter paging = true (https://datatables.net/reference/option/paging).

$('#datatable2').dataTable({
    "aoColumns": [
        { "sType": "numeric-comma" },
        null,
        null,
        null,
        null,
        null],
    "paging": true,
    "oLanguage": { "sSearch": "search: " },
    "oSearch": { "sSearch": "<% = requestId %>" }
});

You can also change pagination type https://datatables.net/reference/option/pagingType

Please not that paging and pagingType parameters were introduced (or rather renamed) in datatables 1.10.

For legacy names of those parameters check https://legacy.datatables.net/usage/options

Update: In order to set the default sorting for the table you have to specify order parameter https://datatables.net/reference/option/order.

Your table initialization will look like this:

$('#datatable2').dataTable({
    "aoColumns": [
        { "sType": "numeric-comma" },
        null,
        null,
        null,
        null,
        null],
    "paging": true,
    "oLanguage": { "sSearch": "search: " },
    "oSearch": { "sSearch": "<% = requestId %>" },
    "order": [[ 0, 'asc' ]]
});

I'm still not sure that I fully understand your question, sorry.

Sign up to request clarification or add additional context in comments.

3 Comments

thanks for your precious time, but there is a strange behavior which I can't understand ,when I use "sType": "numeric-comma" it sort correctly but no paging as the First image in the question , and when I use "sType": "numeric" it view the paging very well but appear the second row with wrong sorting as second image in the question .
Can it be something related to RTL support? Try left-to-right setup.
Sorry can't understand , but I forget to say that the First column is numbers with hyperlink

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.