I have kendo child grid. It's having some row. Each row having some cells. If i change the value of a cell other than first row,i have to get the corresponding first row cell value. That means if i change the second row second column value in child grid i have to get the first row second column value in that grid.
I have written change event of each cell in child grid. On change of any cell value this event will fire. In this event i want to achieve the above functionality. Screen shot is attached.
Code for change of cell is
$('<input maxlength="9" data-bind="value:' + options.field + '"/>')
.appendTo(container)
.kendoNumericTextBox({
format: "0.####",
decimals: 0,
min: 0,
spinners: false,
change: function (e) {
//Here i want to get the first row of this cell value
}
}).off("keydown");
You have two ways to do that. You can get the value from the cell text or from the dataItem, which I prefer.
In your editor
function try this:
function(container, options) {
var $container = $(container),
tdIndex = $container.index(),
$correspondingCell = $container.closest("tbody").find("tr:first td:eq(" + tdIndex + ")"),
dataItem = grid.dataItem($correspondingCell.parent()),
correspondingColumnName = options.field;
// Get from cell's text
console.log("From Cell", $correspondingCell.text());
// Get from dataItem
console.log("From DataItem", dataItem[correspondingColumnName]);
$('<input maxlength="9" data-bind="value:' + options.field + '"/>')
.appendTo($container)
.kendoNumericTextBox({
format: "0.####",
decimals: 0,
min: 0,
spinners: false,
change: function (e) {
// Now this is the corresponding cell's value from first row
console.log("First row's corresponding cell value", this);
}.bind(dataItem[correspondingColumnName]) // <- bind the dataItem's property to the change event
}).off("keydown");
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments