Dependent Field update on inline editing
Dependent Field update on inline editing

I have a dependent field in my table and needed to update it with some calculation on inline editing .
{ data: null,
"render": function (data, type, row)
{ var t = (data["_Exapnd_Value"] - data["_Item_TotalAmount"])
return t.toLocaleString()+".00" }
But the thing is i needed to update the database also with this value . and display in the table also.
any ideas how i can achieve this ?
Thank You
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Just to confirm, you are storing the calculated value in the database? But also calculating it on the client-side? If so, then two options spring to mind:
->setValue()
method to set the calculated value).Allan
@allan Thanks Allan
Value is calculated by a another value entered by the client . so then it should save to database with the calculated value and displayed in the table. i think setvalue() mehod is great . do you know anywhere i can find example calculation done using setvalue() method?
I'm not clear why you are doing the calculation, storing the result in the database, and then doing the calculation again when drawing the table?
There is a
setValue
example here. The data submitted from the form is available in the$values
array.Allan
its a very simple scenario @allan .a table contains two fields which are "current
payment" and "current total".
client has to enter and value which is a payment he put monthly .
and the amount he entered should deduct from the total amount he took as a loan.
it is a also a field in the datatbase. (total = total -payment)
so when he enteres the value it should deduct from the total value.
so as you can see calculation should happen within the time he enters the payment
and also both fields should update as last payment and current total.
im doing a C# MVC project. so where can i perform the calculation at run time? is it possible within setvalue() method like :
Extremely sorry for the disturbance.
You'd do it in
PreEdit
event handler. I linked to the PHP docs before not realising you were using C#. The C# docs might help a little more!.Allan
@allan Thanks a Lot ill put the code below for someone else who looks for the same
using (var dbs = new DataTables.Database(setting.DbType, setting.DbConnection))
{ var responsee = new Editor(dbs, "_IOU_Details", pke = "Detail_ID")
.Model<DetailsDatatables>()
.Where("Header_ID", j);
responsee.Field(new Field("_TotalIOUAmount"));
responsee.Field(new Field("_IOUAmount"));
responsee.PreEdit += (sender, e)
=>responsee.Field("_TotalIOUAmount").SetValue(Convert.ToDecimal(e.Values["_TotalIOUAmount"].ToString()) + Convert.ToDecimal(e.Values["_IOUAmount"].ToString()));
var response = responsee
.Process(reques)
.Data();
}