When one value is updated, search and replace all occurrences of previous value with new
When one value is updated, search and replace all occurrences of previous value with new

Here’s a new one.
I am thinking of having the end users be able to define three choices for a select field. If they go back in and change these options, I would like to take the old value, search all records for it and replace with the new value on submit of the form when they define the value. Too much?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Are these changes to the table row data in the client only or do you need to update a database on the server?
Client side you could use
rows().every()
with arow-selector
as a function to filter the rows that match the old value. Then userow().data()
to update the row data with the new value.For server side update I would probably use an ajax request that sends the old and new values in the
data
option to a specific server url (script) to execute a DB query to update the table. For a sql like DB I would do something likeupdate my_table set my_column = "new_value" where my_column = "old_value"
. In thesuccess
function useajax.reload()
to refresh the Datatable.Kevin
Client side only, no servers for this project.
How do you still know the old value I guess is my stumbling block here.
Do I just set a variable with each of the three values anytime the edit form is open so that I can Terence them on close or is there some sort of useful api for that?
AFAIK there is nothing that keeps track of the previous value in a select. Using a variable to keep track when the form is open sounds like a good way to go.
Kevin
Thanks, going to give it a shot.