@Html.EJ().DropDownList("Column1").Datasource((IEnumerable<Column1>)ViewBag.Column1).DropDownListFields(f => f.Value("ID").Text("Name")).CascadeTo("Column2").EnableFilterSearch(true).HeaderTemplate("<div class='temp' style='margin:10px;'><input id='col1_check' type='checkbox' /></div>").ShowCheckbox().ClientSideEvents(ce => ce.Create("col1_create").PopupHide("col1_popupHide").Cascade("col1_cascade").Change("col1_change").PopupShown("col1_OnShow")).WatermarkText("All").PopupHeight("250")
I tried something like below but I was unable to get it to work. Any Ideas?
function col1_cascade(args) {
args.requiresDefaultFilter = false;
var obj = $("#Column1").ejDropDownList("instance");
if (obj.getSelectedValue() != "") {
args.cascadeQuery = ej.Query().where("Column1ID", "equal", args.cascadeValue);
} else {
args.cascadeQuery = ej.Query().where("Column1ID", "equal", "");
}
}
<script type="text/javascript">
ej.DropDownList.prototype._cascadeDataBind = function (cascadeDropDownObj, changedSource, status) {
var cascadeVal = cascadeDropDownObj.value();
if ((this.model.showCheckbox && status) || (this.model.multiSelectMode != "none" && this.activeItem.hasClass("e-active"))) {
this._changedSource = (!ej.isNullOrUndefined(this._changedSource)) ? this._changedSource.concat(changedSource) : changedSource;
}
else if (!this.model.showCheckbox && this.model.multiSelectMode == "none") this._changedSource = changedSource;
else {
for (var i = 0; i < changedSource.length; i++) {
if (this._isPlainType(changedSource) && this._isPlainType(this._changedSource)) this._changedSource.splice(this._changedSource.indexOf(changedSource[i]), 1);
else {
for (var j = 0; j < this._changedSource.length; j++) {
if (JSON.stringify(this._changedSource[j]) == JSON.stringify(changedSource[i]))
this._changedSource.splice(j, 1);
}
}
}
cascadeDropDownObj.setModel({ dataSource: null });
}
var cascadeModel = JSON.parse(JSON.stringify(cascadeDropDownObj.model)), enable;
this._changedSource.length == 0 ? cascadeDropDownObj.setModel({ dataSource: this[this.model.cascadeTo.split(",")], enabled: this._changedSource.length >= 0 }) : cascadeDropDownObj.setModel({ dataSource: this._changedSource, enabled: this._changedSource.length > 0 });
if (!this._isSingleSelect()) cascadeDropDownObj.selectItemByValue(cascadeVal);
if (cascadeDropDownObj.model.showCheckbox || cascadeDropDownObj.model.multiSelectMode != "none") {
$("input:hidden[id^='#'][name=" + cascadeDropDownObj._id + "]").remove();
}
if (!cascadeDropDownObj._setSelectedItem) {
var selectProp = ["value", "text", "selectedIndex", "selectedIndices"];
for (var m = 0; m < selectProp.length; m++)
cascadeDropDownObj.model[selectProp[m]] = cascadeModel[selectProp[m]];
cascadeDropDownObj._finalize();
}
else {
cascadeDropDownObj.setModel(cascadeDropDownObj._setCascadeModel);
}
cascadeDropDownObj._setSelectedItem = true;
};
</script> |