I have finally tracked down a bug in Grid.hideColumn() that has been troubling me for months.
if you call hideColumn() when you grid is not visible because the grid elements is 0 width or height, or otherwise not visible, the column will not be hidden, and the grid will be in an inconsistant state, with columns assuming other columns widths and other weird behavior.
This occurs for me when including a Grid in a Tab that has a fade in animation. If you programatically hide columns in the Grid on document load while the tab is still fading in, the grid will not be visible and hideColumn will fail.
This is caused by the use of the :visible custom jquery selector in the selector to find the grid column header or footer cell.
from the JQuery documentation.
"Elements are considered visible if they consume space in the document. Visible elements have a width or height that is greater than zero."
Even though the JQuery documentation states
"During animations that hide an element, the element is considered to be visible until the end of the animation. During animations to show an element, the element is considered to be visible at the start at the animation."
This does not appear to be the case, at least for a kendoui tab strip builder with ".Animation(a => a.Open(o => o.Fade(FadeDirection.In).Duration(200)));" set as the animation. I assume the above quote does not apply to elements that are hidden because of parent elements animations.
The fix for the issue is to avoid the :visible selector in the Grid.hideColumn() method and use a filter instead.
Change:
to
if you call hideColumn() when you grid is not visible because the grid elements is 0 width or height, or otherwise not visible, the column will not be hidden, and the grid will be in an inconsistant state, with columns assuming other columns widths and other weird behavior.
This occurs for me when including a Grid in a Tab that has a fade in animation. If you programatically hide columns in the Grid on document load while the tab is still fading in, the grid will not be visible and hideColumn will fail.
This is caused by the use of the :visible custom jquery selector in the selector to find the grid column header or footer cell.
from the JQuery documentation.
"Elements are considered visible if they consume space in the document. Visible elements have a width or height that is greater than zero."
Even though the JQuery documentation states
"During animations that hide an element, the element is considered to be visible until the end of the animation. During animations to show an element, the element is considered to be visible at the start at the animation."
This does not appear to be the case, at least for a kendoui tab strip builder with ".Animation(a => a.Open(o => o.Fade(FadeDirection.In).Duration(200)));" set as the animation. I assume the above quote does not apply to elements that are hidden because of parent elements animations.
The fix for the issue is to avoid the :visible selector in the Grid.hideColumn() method and use a filter instead.
Change:
hideColumn:
function
(column) {
.
.
.
that.thead.find(
">tr>th:not(.k-hierarchy-cell,.k-group-cell):visible"
).eq(columnIndex).hide();
if
(footer) {
that._appendCols(footer.find(
"table:first"
));
footer.find(
".k-footer-template>td:not(.k-hierarchy-cell,.k-group-cell):visible"
).eq(columnIndex).hide();
}
.
.
.
that.thead.find(
">tr>th:not(.k-hierarchy-cell,.k-group-cell)"
).filter(
function
() {
return
$(
this
).css(
"display"
) !=
"none"
; })
.eq(columnIndex).hide();
if
(footer) {
that._appendCols(footer.find(
"table:first"
));
footer.find(
".k-footer-template>td:not(.k-hierarchy-cell,.k-group-cell)"
).filter(
function
() {
return
$(
this
).css(
"display"
) !=
"none"
; })
.eq(columnIndex).hide();
}