当网格具有隐藏列时,增强Kendo网格(jQuery)的最小宽度
我正在尝试对Kendo网格中可调整大小的列强制执行最小宽度规则.我使用了他们提供的示例此处.在他们的示例中,所有列均被显示.在我的情况下,有些列是隐藏的.我有一个示例此处,使用Kendo的Dojo来说明我的问题.隐藏列之后的任何列都不再维护最小宽度规则.最好的是,这是jQuery的问题,它与已设置为display:none;
的元素的交互.
I am trying to enforce a min-width rule for resizable columns in the Kendo Grid. I used the sample that they provided here. In their example all of the columns are being displayed. In my case there are some columns which are hidden. I have a sample here using Kendo's Dojo to illustrate my problem. Any column that comes after the hidden column no longer maintains the min-width rule. Best I can figure is that this is an issue with jQuery and it's interactions with elements that have been set to display:none;
.
如果有一种变通方法可以强制执行最小宽度,请告诉我.
If there is a work-around to get the min-width to be enforced please let me know.
回头再看一遍后,我发现了这个问题.问题在于,当在Kendo网格中隐藏一列时,<th>
元素将设置为style="display:none;"
,但实际上会删除<col>
元素.这意味着<th>
元素的数量与<col>
元素的数量不匹配,因此当设置宽度时,<col>
的索引值将关闭.为了获得正确的索引,您必须获取全部<th>
元素的:visible
子集中的<th>
元素的索引.
I figured out the problem with this after going back and taking another look. The problem is that when a column is hidden in the Kendo Grid the <th>
element is set to style="display:none;"
but the <col>
element is actually removed. This means that the number of <th>
elements does not match the number of <col>
elements, so the index value for the <col>
is off when the width is being set. To get the correct index you must get the index of the <th>
element within the :visible
subset of the total <th>
elements.