Layui text editing changes

If I had to change as shown below in tabular data directly:
Here Insert Picture Description
Edit Note this quantity discount table, etc. How to save the database?
The first step is the introduction of layui plug-in module table
second step first add edit the corresponding table: 'text' property
and then write in the script, the text editor to listen to events
// sales table directly edit
table.on ( 'edit (SellTable) ', function (obj) {
// NOTE: edit event name is fixed, test the properties the container is an original table lay-filter = "a value corresponding to"
var = obj.value text; // get the modified value
var State = obj.field; // current edit field name
var ID = obj.data.id ID // row of
values obtained at the output //
the console.log (text)
the console.log (State)
the console.log (ID)
// value of the acquired parameter passing to the controller are passed to the
$ .post ( "selltableCompile", {ID: ID, text: text, State: State}, function (Data) {
// Get controller return data, and determines whether the condition is true
iF (== data.State to true) {
// return corresponding to different states according to the tips
layer.msg ( "modified successfully", {icon: 1});
} the else {
layer.msg ( "modification failure, discount maximum 1, minimum 0.01", {icon: 2})
}
})
}); / / /

Illustrated as follows: This is the return value of the number of modification I
Here Insert Picture Description
when these values to the controller
// Instantiate entity class
ReturnJson returnjson new new ReturnJson = ();
// definition of state, when the states to a default value
returnjson.State to true =;
// page id data type to data type int
int ID = Convert.ToInt32 (id);
the try
{
// the data corresponding to the selected id
var Selld = (TB in myEntities.B_SellDetail from
WHERE TB == ID .SellDetailID
SELECT TB) .Single ();
// determines whether I modified form fields is the Discount
iF (State == "the Discount")
{
// is selected, then the corresponding data will be assigned to the data field
Selld.SellDiscount = Convert.ToDecimal (text);
// save the changes and
myEntities.Entry (Selld);
myEntities.SaveChanges ();
}
// return the last entity class
return Json (returnjson, JsonRequestBehavior.AllowGet);
before modification data

Here Insert Picture Description
After modifying the data
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/weixin_44552168/article/details/92760437