I have a kendo grid in my project when I add new row for first time it will default focus on first cell , then I delete row or update row or refresh row it will not focus on first cell anymore after I add new row again. Here is my code:
departmentGrid = $("#departmentcfggrid").kendoGrid({
columns: [
{
field: "DepartmentName",
title: DepartmentConstants.lbDepartmentName,
width: 250,
headerTemplate: "<span id='DepartmentName_MandatoryTooltip'></span>" + DepartmentConstants.lbDepartmentName,
editor: function (container, options) {
//Create an input element
var input = $('<input id="DepartmentNameTextBox" placeholder="' + DepartmentConstants.lbDepartmentName + '" class="k-input k-textbox" data-bind="value:' + options.field + '">');
input.attr("name", options.field);
input.attr("maxlength", 100);
//Append it to the container
input.appendTo(container);
input.keyup(function (e) {
if (fqtt_CheckKeyCodeForInput(e.keyCode)) {
var pickupvalue = $(this).val();
var currentRow = $(this).closest('tr');
//Set value for checkbox
var dataItem = departmentGrid.dataItem(currentRow);
dataItem.set('DepartmentName', pickupvalue);
fqtt_ControlButtonGridDepartment();
}
});
}
}
]
Here is add new row event:
$("#departmentcfggrid .k-grid-add-department").click(function () {
if (fqtt_ValidationAddNewDepartmentsInGridData()) {
departmentGrid.addRow();
$("#DepartmentNameTextBox").focus();
fqtt_ControlButtonGridDepartment();
}
});
Please help me, thanks.
var view = this.dataSource.view();
if(view.length>0){
this.select(this.table.find("tr[data-uid='" + view[0].uid + "']"));
}
in place of $("#DepartmentNameTextBox").focus(); It worked for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.