Soft Edit
Soft Edit
There are a couple hints on this forum indicating there is a easy way to enable a soft edit. I need more conclusive information than the hints I found elsewhere on the forum.
Essentially what I want to do is mark a existing row as bool named "OldVersion", and otherwise leave it unchanged and create a new row with the edited information.
This would give me a very nice history of edits.
Here is my database insert part of my controller.
using (var db = new Database(settings.DbType, settings.DbConnection))
{
var response = new Editor(db, "GR_AlternativeBilling", "TableID")
.Model<GR_AlternativeBilling>()
.Where("OldVersion", false, "=")
.TryCatch(false)
.Process(requestCreate)
.Data();
return Json(response, JsonRequestBehavior.AllowGet);
}
This question has an accepted answers - jump to answer
Answers
Here is a button that allows you to create a new record based on an existing record:
This is how you would use the button in the "buttons" section of your data table:
And this is what you need to do to send a variable called "selected_id" to the server as a POST variable.
With that posted value you can update the copied record on "writeCreate" of the new record, for example.
https://editor.datatables.net/manual/net/events
Edit: Since I do the "deselect" of the copied record on "close" of the editor, you might need to save the existing record's id in a global variable on "select" of the existing record, so that you can send it to the server. You will figure that out I guess
You could do the update of "oldVersion" in one go using the client side Editor on "submitSuccess" like this. No need to do additonal server side updates in that case. No need for "ajax.data" in that case either.
Thanks RF.
I'm not strong with javascript so instead of struggling on the javascript side I decided to take your idea and do all the trickery serverside in C#. I made a deep copy of the form and edited the original form to only update "oldVersion" with a edit db function and used the new fresh copy of the form to do a create db function.