EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: bduguay on March 30, 2015, 10:11:38 AM



Title: Treegrid cell focus not working in 1.4.2
Post by: bduguay on March 30, 2015, 10:11:38 AM
I have a tree grid that when the user presses the space bar on the row, it focuses and selects the cell and allows them to edit it the data. When I upgraded to 1.4.2 the focus will no longer set on the field. The field to have focus is based on data already in the row.

The only thing that I've changed on my page are my script tags to point to the new easyui files. I even tried to include the patch on my page, but it changed nothing.

The fields are numberboxes.

Code:
// Select the cell to start editing in.
function selectCellToEdit(row) {
    // Get the editor for the treegrid based on if the row hasAssociates
var editor;
if (row.hasAssociates) {
// Set the focus based on if the hours need to be calculated for the row.
if (row.calculateHours) {
editor = $(currentGrid).treegrid('getEditor', {id:editingId, field:'businessPlanAssociates'});
} else {
editor = $(currentGrid).treegrid('getEditor', {id:editingId, field:'businessPlanHours'});
}
} else {
editor = $(currentGrid).treegrid('getEditor', {id:editingId, field:'businessPlanAmount'});
}
// Set focus in the cell and select the text
$(editor.target).focus().select();
}


Title: Re: Treegrid cell focus not working in 1.4.2
Post by: jarry on March 30, 2015, 03:22:48 PM
Please refer to this example http://www.jeasyui.com/demo/main/index.php?plugin=DataGrid&theme=default&dir=ltr&pitem=Row%20Editing%20in%20DataGrid


Title: Re: Treegrid cell focus not working in 1.4.2
Post by: bduguay on March 31, 2015, 05:15:56 AM
Thank you.

The following code worked.
Code:
($(editor.target).data('textbox') ? $(editor.target).textbox('textbox') : $(editor.target)).focus().select();