Hi, I removed the isPrimaryKey (so there is no field setting as primary key), but it still does not focus on the first field <Account>. It seems the focus is on grid toolbar and I have to press tab to receive focus on 1st field. Please see my video: https://www.screencast.com/t/jHGob1qKiUEb.
The idea for the empty record on the grid is: User does not have to click "+" toolbar icon to create a new row. There's always an empty record on the grid, so that user can enter new data on that row --> press enter --> data is saved and a new empty row will appear with focus setting on first field <Account>.
$(function () {
// the datasource "window.gridData" is referred from jsondata.min.js
var data = [{ EmployeeID: "", OrderID: 1000, Freight: " ", ShipName: " ", ShipCountry: "" }];
var data = window.gridData;
$("#Grid").ejGrid({
dataSource: data,
allowPaging: true,
allowSorting: true,
allowGrouping: true,
allowMultiSorting: true,
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, editMode: "normal", showAddNewRow: true },
columns: [
{ field: "OrderID", width: 80, isPrimaryKey: true, visible: false, textAlign: ej.TextAlign.Right, headerText: "Order ID" },
. . .
]
});
});
|
$("#Grid").ejGrid({
dataSource: data,
. . .
columns: [
{ field: "AutogeneratedColumn", width: 80,isIdentity: true, isPrimaryKey: true, visible: false, textAlign: ej.TextAlign.Right, headerText: "Order ID" },
{ field: "EmployeeID", foreignKeyField: "EmployeeID", foreignKeyValue: "FirstName", dataSource: window.employeeView, width: 75, headerText: "First Name" },
. . .
]
});
}); |
If I changed the columns order to: debit, account_id, credit, comment, then it works fine too: The focus is on debit field --> press tab and the focus is on account_id field.
I figured it out, I just need to set focus on the hidden field of <account_id>:
write(args) {
args.element.ejDropDownList({
enableFilterSearch: true,
dataSource: args.column[0].dataSource,
value: args.rowdata.account_nr,
fields: { text: "account_text", value: "account_nr" },
});
$('#gridAccountingaccount_id_hidden').focus();
}
So now could you please help me with this: when user finish editing a row and press Enter, the next row is edited and focused (as if user click Edit icon for the next row) ?
$("#Grid").ejGrid({
// the datasource "window.gridData" is referred from jsondata.min.js
dataSource: window.gridData,
allowPaging: true,
actionComplete:function(args){if(args.requestType == "save"){
var currentEditRowIndex= args.selectedRow;
this.selectRows(currentEditRowIndex+1); //select the immediate next row of edited record
this.startEdit();//edit the selected record
}},
columns: [
. . .
]
});
|
Thank you.