Edit and Delete Records

Edit and Delete Records

dtw11dtw11 Posts: 18Questions: 4Answers: 0

I want to edit and delete records from a custom column with associated icons. I can not use editor plugin. So I want to transform the row probably with a template with textboxes on click add changes and them save which will refresh the record set and remain on the location in the pagination. Same with delete. Thanks

Answers

  • dtw11dtw11 Posts: 18Questions: 4Answers: 0

    So as a test I added an event to my custom column icons for edit and delete. It was a simple alert popup. The first page of my table works as expected but anything beyond the first 10 the event will not fire. Why would anything beyond the initial page loaded items not be active?

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Why would anything beyond the initial page loaded items not be active?

    Second top FAQ :smile:.

    Q. My events don't work on the second page

    Allan

  • dtw11dtw11 Posts: 18Questions: 4Answers: 0

    I am using pagination default 10 per page. All events work on that page when clicking on the icons in the icon column or I also tested and event on the the row which worked. Then if I page to any other page using the navigation the evens no longer fire. When return to the first page the work again.

  • dtw11dtw11 Posts: 18Questions: 4Answers: 0

    This is the fix for the pagination past initial records. I was using a more focused scope for the selector. Now I need to figure out how to change the underlying records in the array and post back changes to the db while staying in the current position in the data.

    https://datatables.net/examples/ajax/null_data_source.html

  • dtw11dtw11 Posts: 18Questions: 4Answers: 0

    So I am using the data source method for data arrays or objects https://datatables.net/examples/data_sources/js_array.html. Using an event triggered by onclick for the delete icon a sql statement deletes the row. I want to keep the location in the recordset and refresh the records without the deleted item. Is that possible? I have looked at saveState but unsure if that is a way or how to implement that. Can you comment on that? This needs to apply on a bigger picture to include any events like pagination and search as well. Thanks

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    What is causing the table to change its paging position at the moment? Both draw() and ajax.reload() have options to keep the page where it is.

    Allan

  • dtw11dtw11 Posts: 18Questions: 4Answers: 0

    This article works https://datatables.net/reference/api/row().remove. The problem is not completely solved though. Since I am using javascript method for data not ajax (can't use server side methods because there is no server the page acts as a desktop app called from the desktop and uses activex to connect to the database) so I don't see how to refresh the page. I do want to call the database again and return the current records to the page. If I then page forward without refreshing the records from the database first. All records will shift by one record. The next page will skip what was the original record. I also have to maintain the state for current page number, and if there are any filters or sorts in place so if I do reload the page it will stay on its current page of records minus the deleted and bring in the next record in the list. I did wonder if I could use jquery to make an ajax call without a url but not sure how to put a jquery ajax call together with the datatable?

This discussion has been closed.