How to hide rows instead of deleting them in DataTable pagination switch

How to hide rows instead of deleting them in DataTable pagination switch

After switch between pages in pagination view, DataTable remove another "tr" and keep only called page rows (tr),
how to hide them instead of deleting, look at this picture please:

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 21,166Questions: 26Answers: 4,921

    I think what you are looking for is in this thread. See Colin's example:
    https://datatables.net/forums/discussion/comment/137757/#Comment_137757

    Kevin

  • mirzaei.sajad@hotmail.commirzaei.sajad@hotmail.com Posts: 9Questions: 2Answers: 0
    edited December 2019

    @colin
    Thanks for reply, I did what you said in this url:
    http://live.datatables.net/tubisanu/1/
    You will change the data values on both pages then click on "Click here for GetSum" , you will see that it will give you the sum of the values on the same page, not all pages.

  • mirzaei.sajad@hotmail.commirzaei.sajad@hotmail.com Posts: 9Questions: 2Answers: 0
    edited December 2019

    @kthorngren
    thanks Kevin,
    My problem is different, please look at this url:
    http://live.datatables.net/tubisanu/1/

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Thank you for the fiddle, but I'm sorry, I'm really not following. Could you give step by steps with that last fiddle on how to reproduce your issue, and what you would expect to happen instead, please.

    Colin

  • mirzaei.sajad@hotmail.commirzaei.sajad@hotmail.com Posts: 9Questions: 2Answers: 0
    edited December 2019

    @colin
    First, thank you very much for your response,
    look at this url please:
    http://live.datatables.net/tubisanu/2

    I entered values 1, 4, 5 on the first page (Data column),

    then, I entered values 4, 3 on the second page,

    Then I click on the "Click here for GetSum",
    I expect to see in front of the "Sum" sum of all values,
    I expect to see sum of all values ( Sum: 17 ),
    But the number I see is 7,

    Because in DataTable you can only see the sum of the values entered on the last page, But I want to have sum of values entered on all pages.

  • colincolin Posts: 15,237Questions: 1Answers: 2,598
    Answer ✓

    Gotcha, you can do something like this: http://live.datatables.net/fuxosopu/1/edit

    Colin

  • mirzaei.sajad@hotmail.commirzaei.sajad@hotmail.com Posts: 9Questions: 2Answers: 0

    @colin
    Thanks..
    Great for the new tables I want to build,
    But I have a project with about 800 pre-built tables in specified files..
    I want to add to DataTables framwork now, and I'm having trouble
    I have to change about 800 tables, it takes a long time
    Is it possible or option for DataTable to hide records in the body of table instead of deleting them? (look at the first comment please)

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    You can't hide, only row().remove() to remove them. Even if you could remove, wouldn't changing that code also the same effort to change for those 800 tables?

    Colin

  • mirzaei.sajad@hotmail.commirzaei.sajad@hotmail.com Posts: 9Questions: 2Answers: 0
    edited December 2019

    @colin
    The project was made with C# and the tables were designed with "ASP:GridView"
    And the sum of values is taken to the server with C#
    So it's not possible to access client side rows and columns unless it puts all these values in a field and passes them to the server side(c#).
    This problem would have been solved if DataTable was hiding them(rows) after each filter rather than deleting rows

  • kthorngrenkthorngren Posts: 21,166Questions: 26Answers: 4,921

    Datatables manipulates the DOM to display only the rows for the page being displayed. All the data is contained in the Datatables data cache and you can access it using Datatatables APIs like rows().data(). You will need to change the code you are using to obtain the data now to usie one of the Datatables APIs.

    Kevin

  • mirzaei.sajad@hotmail.commirzaei.sajad@hotmail.com Posts: 9Questions: 2Answers: 0

    @kthorngren
    Thanks my friend, I know
    My problem is when you want to modify that user-side information(In the Table drawn) and send it to the server.

    Anyway,
    Thanks to all,
    DataTable is really the best.

This discussion has been closed.