requery leftJoined value after field change
requery leftJoined value after field change
In my MVC project I have a field which in the controller, has a LeftJoin to another table. during an .on(change) of the field, is there a way to 'requery' the leftjoin?
CaseActionsEditor.field('CaseActions.ActionStatusID').input().on('change', function (e, d) {
//console.log("D: " + JSON.stringify(d));
//console.log("E: " + JSON.stringify(e));
if (d === undefined) { // The change was triggered by the end user on update rather than an auto set
var actionID = CaseActionsEditor.get("CaseActions.ActionID");
var isComplete = CaseActionsEditor.get("ActionStatus.IsComplete");
if (actionID == 1) { //Out for Delivery
var actionStatusID = CaseActionsEditor.get("CaseActions.ActionStatusID");
$.ajax({
url: 'api/ActionStatus?actionID=0&actionStatusID=' + actionStatusID,
dataType: 'json',
success: function (response) {
isComplete = response.data[0]["ActionStatus"]["IsComplete"];
if (isComplete == 1) {
CaseActionsEditor
.show("DefaultDate")
.field('DefaultDate').input().addClass('redInputbox');
} else {
CaseActionsEditor.hide('DefaultDate');
}
}
});
}
}
});
On Line 6, the value is still what it was when the editor was opened. if i was able to requery the value in the left join I would not need to do the following ajax call
.LeftJoin("ActionStatus", "ActionStatus.ActionStatusID", "=", "CaseActions.ActionStatusID")
.Field(new Field("ActionStatus.StatusName").Set(false))
.Field(new Field("ActionStatus.IsComplete").Set(false))
Or, on the select options, is there a way to include the IsComplete value that I can reference later?
.Field(new Field("CaseActions.ActionStatusID")
.Validator(Validation.NotEmpty())
.Options(new Options()
.Table("ActionStatus")
.Value("ActionStatusID")
.Label("StatusName")
)
)
This question has an accepted answers - jump to answer
Answers
Currently no - sorry, the Ajax call is required since it isn't currently possible to have additional meta information per option in Editor. There is just the label and the value - anything else needs to be queried from somewhere (the server in this case).
Allan
ok, thanks. thought i would check, because there are so many gems yet for me to discover with DataTables