How to return to the original page after editing a record

How to return to the original page after editing a record

TomBajzekTomBajzek Posts: 163Questions: 36Answers: 1

The DataTables/Editor package has been very valuable for what I've been doing. I'm very pleased! Thank you for producing such a great tool.

However, I do come across things I'd like to do that do not have an obvious (to me) implementation. In this case, there is a behavior I need to change: After you click 'Update" to save an edit, the selected page reverts to the first page of the set, even if the record that was edited is on some other page. As a result, the user loses his place in the edited table. (This does not happen if you cancel the edit with the 'X' button, or if you do not change any data, but if you make an actual change, you lose you place at once.)

I have not seen a way to control this is the Editor, or in DataTables. Does DataTables/Editor offer a way to do preserve the pre-edit page, or do I need to invent one. Is there an existing data field that I should be working with?

Thanks,
Tom

Replies

  • tangerinetangerine Posts: 3,350Questions: 37Answers: 394

    The basic example for Editor shows updated rows remaining in place unless the update affects the column currently nominated for sorting, in which case the row is likely to be sorted away from the current page.
    Is that not the behaviour you are seeing?

  • TomBajzekTomBajzek Posts: 163Questions: 36Answers: 1

    Actually, there is a bit more to this, which I recalled after seeing your response:

    When the user clicks 'Update" in the edit pane, the record is correctly saved, but it is not updated on the screen. To make that happen, I've had to do an ajax.reload() on a successful update. I think that reload is why I'm losing the page that was updated.

    It seems that I can only get one of the two desired behaviors. How can I make the updated record appear correctly on the screen without doing the reload?

    Thanks,
    Tom

  • kthorngrenkthorngren Posts: 20,302Questions: 26Answers: 4,769

    ajax.reload() has a resetPage parameter you can set false to stay on the same page. For example

    ajax.reload( null, false )

    Kevin

  • TomBajzekTomBajzek Posts: 163Questions: 36Answers: 1

    Kevin,

    That takes care of it! It works like a charm.

    Thanks,
    Tom

This discussion has been closed.