Morning, I have the following table:
var hot = new Handsontable(container, {
data: @Html.Raw(Json.Encode(Model.Decisions)),
cells: function(row, col) {
var cellProperties = {};
cellProperties.renderer = "rowColourRenderer"; // uses lookup map
return cellProperties;
},
beforeChange: function(changes, src) {
//if (src !== 'internal-call') {
// this.setDataAtCell(changes[0][0], 2, 'Row changed', 'internal-call')
//}
var row = changes[0][0];
alert("row: " + row);
var reason = changes[0][3];
alert("new reason: " + reason);
var decision = hot.getDataAtCell(row,0);
alert("decision: " + decision);
var temp = getReasonFromDecision(decision, reason);
alert("temp: " + temp);
//this.setDataAtCell(changes[0][0], 1, temp, 'internal-call')
},
…
and I am trying to call a function getReasonFromDecision passing decision and reason. But my page hangs. I’m not sure what I’m doing wrong. My function is:
function getReasonFromDecision(decision, reason) {
var temp = Model.ReasonFromDecision(decision, reason);
return temp;
}
and in the model the code is:
public string ReasonFromDecision(string decision, string reason)
{
string temp = “”;
if (string.IsNullOrEmpty(reason))
{
List decisions = db.DecisionCodes.ToList();
var result = (from d in decisions
where d.Code == decision
select d).FirstOrDefault();
temp = result.Reason == null ? "" : result.Reason;
}
else
{
temp = reason;
}
return temp;
}
The code is never run in the model - I have a breakpoint there.