Value not saved
Value not saved
tomleong
Posts: 13Questions: 5Answers: 0
Hi all,
I use an editor to allow user to edit order lines. if user changes the order quantity, then the order amount will be computed (order quantity * unit price) again. But the amount can not be updated to my MS SQL database after editing.
Can anyone tell me what i am missing? I am using inline editing.
editor.on('preSubmit', function (e, o, action) {
if (action !== 'remove') {
var orderQuantity = this.field('orderQuantity');
var unitPrice = this.field('unitPrice');
var amount = this.field('amount');
amount.val(parseFloat(orderQuantity.val()) * parseFloat(unitPrice.val()));
alert(amount.val().toString());
editor.submit();
// If any error was reported, cancel the submission so it can be corrected
if (this.inError()) {
return false;
}
}
});
Thanks.
Best regards,
Tom Leong
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This discussion has been closed.
Answers
You don't need the
editor.submit()
on line 9 as Editor is in the process of submitting already. Could you remove that and see if it helps.Colin
Dear Colin,
i removed the line but the script still could not update the calculated fields into SQL table. The following are the script of my editor and datatable. Please advise if any.
Thanks.
Best regards,
Tom
I just noticed you're not setting the value of the field - you can use
field().set()
to do that. This thread here should helpful, as it's demonstrating different ways to set the field.Colin
Dear Colin,
I finally fixed my problem as below.
1 - Change the submit to 'allIfChanged'
2 - Use $.each to set the value into field amount.
Thanks.
Best regards,
Tom