Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
in my viewmodel i have copule of properties nad base on that i wrote computed function.

I am assigning value of my computed function to textbox which is displying NAN as a value on view side

HTML
<div class="dx-field">
                                <div class="dx-field-label">Line Value:</div>
                                <div class="dx-field-value" data-bind="dxTextBox:{
                                     value: cCall_OrderProductLineValue,
                                     readOnly: true
                                     }"></div>
                            </div>


What I have tried:

cCall_OrderProductName: ko.observable('New'),
cCall_OrderProductQty: ko.observable(10),
cCall_OrderProductPrice: ko.observable(350),
cCall_OrderProductDiscount: ko.observable(5),
cCall_OrderProductFreeQty: ko.observable(4),
cCall_OrderProductLineValue: ko.computed(function () {
result = parseInt((this.cCall_OrderProductPrice * this.cCall_OrderProductQty) - ((this.cCall_OrderProductPrice * this.cCall_OrderProductQty) * (this.cCall_OrderProductDiscount / 100)));
return result;
}, this),
Posted
Comments
Sergey Alexandrovich Kryukov 25-May-16 10:06am    
Your calculated result can be NaN (floating-point not a number), and when you call ToString, it becomes string "NAN", so what? NaN is NaN...
One of operands can be NaN and so on... Use the debugger.
—SA
Philippe Mori 25-May-16 20:02pm    
Use code block for code in what I have tried section. Also properly indent code in first code block. You have to make some effort if you want other to help you. I would also suggest you to fix spelling errors.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900