Problem with Pagination with Tables


Topic: Problem with Pagination with Tables

traveller_650 asked 2 years ago

Expected behavior I want to use datapagination component in a table with all possible permissions of a Role.

On get event of my page, I load ALL permissions in a list with its data (GroupName, Description, permission and Selected), for using a table with information&checkbox within of a Form with more field (Name and Description of Role).

This work fine until here.

Actual behavior

On post event, my List only has filled the information of the permissions show in the screens (by default 10 entries), the rest are null.

Why?

Thanks in advance

enter image description here


Mateusz Łubianka staff commented 2 years ago

Hi @traveller_650,

Do you use pagination? 10 items per page?

Best,


traveller_650 commented 2 years ago

Hi Mateusz

Yes, I use pagination component.

But in this case, all data of the table are loaded in the client-side (no doing server-side pagination). They are all the permissions in a role of security in my applicattion. I want to save to database all items, no only showed it in that page of the pagination. The permissions are packed&saved in only a field in the database, therefore I need all the items in the memory.

On post event to sumbitting the form, I lost all items no showed in screen. Is this so? How can I save to database all items loaded in the datatable?


Mateusz Łubianka staff answered 2 years ago

@traveller_650,

To get all data use:

$(document).ready(function () {
      let table = $('#dtBasicExample').DataTable();
      $('.dataTables_length').addClass('bs-select');

      console.log(table.data())
    });

To get all rows (even the paginated ones):

var rows = table.rows({ 'search': 'applied' }).nodes();
      console.log(rows)

Best,


traveller_650 commented 2 years ago

Thanks. I will try it


Mateusz Łubianka staff commented 2 years ago

Feel free to contact if you need help.

Best,


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.16.0
  • Device: PC
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No