Rajesh Biswas Rajesh Biswas - 2 months ago 7
jQuery Question

How to bind kendo combo in kenod grid based on Id

I am binding kendo combo in kendo grid. Combo should bind dynamically based on item code from adjacent column. I have written below code. Combo does not bind.

$("#DieItemGrid").kendoGrid({
dataSource: {
data: result,
autoSync: true,
schema: {
model: {
id: 'ParentItemId',
fields: {
ParentItemCd: { type: "string", nullable: false },
ChildItemCd: { editable: false }
}
}
}
},
columns:
[
{
field: "ChildItemCd",
title: "Die Item Code",
headerAttributes: {
style: "vertical-align: middle;"
}

},
{
field: "InternalRevDatalist", title: parentItemCd + "<br>Int. Rev Step",
editor:
function (container, options) {
$.FwAJAX({
showBusyIndicator: false,
url: $.FwRoute.Base() + "GetInternalRevStepList",
data: { itemCd: "#=ChildItemCd#" },//not able to get this id
//data: {itemCd: '10036064'},
dataType: 'json',
success: function (result) {
$('<input required name="' + options.field + '"/>')
.appendTo(container)
.kendoComboBox({
autoBind: false,
dataTextField: "Description",
dataValueField: "FriendlyId",
placeholder: "-- Select --",
dataSource: result,
change: function (e) {
e.preventDefault();
//onchange
}
});
}
});


}
, template: dieinternalRevListTemplate

}
],

dataBound: function () {
var dataView = this.dataSource.view();
for (var i = 0; i < dataView.length; i++) {
var uid = dataView[i].uid;
$("#DieItemGrid tbody").find("tr[data-uid=" + uid + "]").addClass("datadisable");
}
},
editable: true,
selectable: "multiple cell",
});


enter image description here

I am not able to get ChildItemCd. Based on this id I need to fill combobox.

Answer

In your options argument, you have a property called model, which is the model of the current row.

Use it like:

data: { itemCd: options.model.ChildItemCd }

Demo

Comments