I am trying to use MVC's model binding functionality. I have a source that I need to submit to the server and then have it return a value called a Yield to Maturity. The issue is my form is bound to a viewModel. When I do a yieldSource.sync() , the form is submitted with my schema model but nothing is populated.
Here is my code: Originally I was doing gets in the addYieldValues method but that didn't seem to do anything unless I put the values in an array.
Please help.
Here is my code: Originally I was doing gets in the addYieldValues method but that didn't seem to do anything unless I put the values in an array.
Please help.
$(document).ready(function () { var viewModel = kendo.observable({ order : { allocations: [], yieldCalcs: [], TradeDate: "", SettleDate: "", EventType:"", TrustCode: "", Broker: "", BondProceeds: function(){ return this.get("UnderlyingPar") * (this.get("UnderlyingPrice")/100) + this.get("UpfrontFees"); }, UnderlyingPar: "", TrustFee: "", RemarkFee: ".", WrapFee: "", LiquidFee: "", BMASIFMA: "", UnderlyingPrice: "", UpfrontFees: "", FloaterAmount:"", InverseFloatPar:"", LeverageRatio: function(){ return this.get("FloaterAmount")/this.get("InverseFloatPar"); }, ResidualYield: function(){ }, ResidualAmount: "", ResidualPrice: function(){ return this.TotalAmount()/this.get("InverseFloatPar")*100; }, InterestOnFloat: function(){ return this.get("FloaterAmount")*this.get("BMASIFMA"); }, InterestOnAssets: function(){ return this.get("UnderlyingPar") * this.get("UnderlyingCoupon"); }, ProgramFees: function(){ return (this.get("UnderlyingPar") * (this.get("TrustFee") + this.get("WrapFee"))) + (this.get("FloaterAmount") * (this.get("RemarkFee") + this.get("LiquidFee"))); }, UnderlyingYield: ".0375", UnderlyingCoupon: ".05", TerminationDate:"", EffectiveCoupon: function(){ return (this.InterestOnAssets() - this.InterestOnFloat() - this.ProgramFees())/this.get("InverseFloatPar"); }, TotalAmount: function(){ return this.get("UnderlyingPar") * (this.get("UnderlyingPrice")/100) - this.get("FloaterAmount"); }, ResAccInt: function(){ } }, yieldSource: new kendo.data.DataSource({ pageSize: 1, data: this.order, transport: { read: { url: "@Url.Action("GetYield","Home")", dataType: "json" }, create : { url: "@Url.Action("GetYield","Home")", dataType: "json" } }, schema: { model: { fields: { SettleDate: { Type: "Date", validation: {required: true }}, TerminationDate: {Type: "Date", validation: {required: true }}, EffectiveCoupon: { Type: "Number", validation: {required: true }}, ResidualPrice: { Type: "Number",validation: {required: true }}, EffectiveCoupon: {Type: "Number",validation: {required: true}}, ResidualYield: {Type: "Number",validation: {required: true}}, ResidualPrice: {Type: "Number",validation: {required: true}}, InverseFloatPar: {Type: "Number",validation: {required: true}}, LeverageRatio: {Type: "Number",validation: {required: true}}, UnderlyingPar: {Type: "Number",validation: {required: true}}, UnderlyingPrice: {Type: "Number",validation: {required: true}}, UnderlyingYield: {Type: "Number",validation: {required: true}}, UnderlyingCoupon: {Type: "Number",validation: {required: true}}, EventType: {Type: "Number",validation : {required: true}}, TrustCode: {Type: "Number",validation : {required: true}}, Broker: {Type: "Number",validation : {required: true}}, BondProceeds: {Type: "Number",validation : {required: true}}, BMASIFMA: {Type: "Number",validation : {required: true}}, WrapFee: {Type: "Number",validation : {required: true}}, RemarkFee: {validation : {required: true}}, LiquidFee: {validation : {required: true}}, ResccInt: {validation : {required: true}}, TotalAmount: "TotalAmount" } } }, parameterMap: function(options, operation){ if(operation=="create"){ console.log(options); return { models: kendo.stringify(options.models)}; } return options; } }), addYieldValues: function(){ this.yieldSource.add(this.viewModel); this.yieldSource.sync(); },