This is a migrated thread and some comments may be shown as answers.

[Solved] Focus on new row when first column(s) are hidden

5 Answers 324 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian Roth
Top achievements
Rank 1
Brian Roth asked on 25 Nov 2014, 10:55 PM
I think I found a flaw in the logic to get the first editable column when adding a new row to a grid.  I have a grid where the visibility of the first column is toggled on and off based on another control on the page.  When the first column is hidden and the button is clicked to add a new row the first cell is not given focus.  I traced this through the code and came to this function:

_firstEditableColumnIndex: function(container) {
    var that = this,
        column,
        columns = that.columns,
        idx,
        length,
        model = that._modelForContainer(container);
 
    for (idx = 0, length = columns.length; idx < length; idx++) {
        column = columns[idx];
 
        if (model && (!model.editable || model.editable(column.field)) && !column.command && column.field) {
            return idx;
        }
    }
    return -1;
},

It looks like there should be a check for !column.hidden as part of the if condition so that we don't try to set the focus to a cell in a hidden column.  Let me know if that seems correct or if there's a different way I should be handling this situation.  Thanks!

Regards,
Brian

5 Answers, 1 is accepted

Sort by
0
Brian Roth
Top achievements
Rank 1
answered on 25 Nov 2014, 10:55 PM
Forgot to mention - this is a grid with inline editing.
0
Petur Subev
Telerik team
answered on 27 Nov 2014, 04:57 PM
Hello Brian,

Thank you for bringing this issue to our attention. Indeed your finding is correct and I will forward this to the Dev team so they can fix it. 

As a small sign of our appreciation I updated your telerik points.

Kind Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Brian Roth
Top achievements
Rank 1
answered on 16 Jan 2015, 08:12 PM
Hi Petur,

I finally got around to testing on the latest release and am still experiencing the issue.  It seems like the developers fixed an issue with navigation and hidden columns, which is definitely helpful.  But it seems like this same sort of fix still needs to be applied to the _firstEditableColumnIndex method.  Thanks!

Regards,
Brian
0
Petur Subev
Telerik team
answered on 19 Jan 2015, 12:21 PM

Hello Brian,

 

The fix is as follows, but notice it is not included in the production branch. It will be added for the official release next month:

 

 

if (model && (!model.editable || model.editable(column.field)) && !column.command && column.field && column.hidden !== true) {
                   return idx;
}

 

 

 

Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Brian Roth
Top achievements
Rank 1
answered on 20 Jan 2015, 06:47 PM
Thanks!  I've updated my code and look forward to the official release.

Brian
Tags
Grid
Asked by
Brian Roth
Top achievements
Rank 1
Answers by
Brian Roth
Top achievements
Rank 1
Petur Subev
Telerik team
Share this question
or