0

I have a modal that contains a data table.This table has pagination.I want to be able to modify rows from different pages and at the end press a "Save" button that would send the modified rows to the api and update the DB.

So if my table looks like this:

  Page 0      Page 1  ...... Page n
  row0        row0
  row1      **row1**
**row2**      row2

If i have edited the row2 from Page0 and row1 from Page1 ...and etc ...what would be a good option to save the progress?Should i traverse at the end all rows and check if they are modified or add the rows in a list the moment they are changed and send them when pressing Save?

This is my html so far:

<div class="container">
    <div class="row">
        <div class="col-sm-auto">
            <ng2-smart-table class="activitiesTable" [settings]="settings" [source]="data" #activitiesTable></ng2-smart-table>
        </div>
    </div>
    <hr>
    <div class="row">
        <div class="col-sm" style="float:right">
            <button type="button" class="btn btn-default" (click)="Save($event)">Save</button>
        </div>
    </div>
</div>

The source is the data of the table.

Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152

1 Answers1

1

According to my experience, I would suggest to let the users change whatever he wants, then at the end take all rows as json, angular will allow you to do so, then in your api convert it to your model and bulk import results in the database, then re bind the grid.

user123456
  • 2,524
  • 7
  • 30
  • 57
  • Yes i want to do exactly that but isn't it time consuming to send all rows from the table to the api?Shouldn't i track just the modified ones?Either way i see that when i change pages the local changes do not persist.If i modify one row from the first page and then i go to the second page.When returning to the first the changes are not kept locally. – Bercovici Adrian May 12 '18 at 09:40
  • Since you are not keeping local changes o would suggest to have it per page, so in page one you send 10 rows and save etc – user123456 May 12 '18 at 09:43
  • So user changes some rows in a page then has to save .And i send a page this way. – Bercovici Adrian May 12 '18 at 09:46
  • Why not ? It is a good approach, light on server and less work on the client side. – user123456 May 12 '18 at 09:55