[英]ExtJS 5 grid with grouping feature: Selected row with box shadow
I'd like to add a box shadow to the selected row in a grid which also uses the grouping feature. 我想在还使用分组功能的网格中的选定行中添加框阴影。 Initially I just applied the box shadow to the
table
element of the selected row: 最初,我只是将框阴影应用于所选行的
table
元素:
.x-grid-item-selected {
box-shadow: 0 0 6px 2px rgb(119, 119, 119) inset;
}
Unfortunately, the table element of the first row in a group also contains the group header which gave me this result when I selected the first row in a group: 不幸的是,组中第一行的表元素还包含组头,当我选择组中的第一行时,该头为我提供了以下结果:
Also I can't apply the box shadow to the tr
element of the grid row ( .x-grid-item-selected .x-grid-row
) since chrome doesn't support box shadows on tr
elements (at least not without setting their display property to block which would break the layout completely). 我也不能将框阴影应用于网格行的
tr
元素( .x-grid-item-selected .x-grid-row
),因为chrome不支持tr
元素上的框阴影(至少不是没有设置)它们的显示属性将被阻止,这将彻底破坏布局)。
Applying the box shadow to each cell ( .x-grid-item-selected .x-grid-cell
) obviously doesn't give me the desired look neither: 将框阴影应用于每个单元格(
.x-grid-item-selected .x-grid-cell
)显然也不能给我所需的外观:
Here's how I'd like the selected row to actually look like (just for the sake of completeness): 这就是我希望所选行的实际外观(只是为了完整性):
In ExtJS 4 I was able to accomplish this by using the RowWrap feature which was removed with ExtJS 5. 在ExtJS 4中,我能够使用RowWrap功能实现此功能,该功能已在ExtJS 5中删除。
I'd really appreciate if someone could give me some help with this! 如果有人可以给我一些帮助,我将不胜感激!
Here's a fiddle to play around with: https://fiddle.sencha.com/#fiddle/jkv 这是一个玩弄的小提琴: https : //fiddle.sencha.com/#fiddle/jkv
Thanks & best regards 谢谢与问候
Ps.: I've also asked this question on the Sencha Forums 附言:我也在Sencha论坛上问了这个问题
With the suggestion of arthurakay who commented above in mind I was able to find a suitable solution by using linear-gradients
instead of box shadows
which looks something like this: 有了上面提到的arthurakay的建议,我能够通过使用
linear-gradients
而不是像这样的box shadows
找到合适的解决方案:
.x-grid-item-selected .x-grid-cell {
background:
linear-gradient(top, rgb(119, 119, 119), transparent 6px),
linear-gradient(bottom, rgb(119, 119, 119), transparent 6px);
// Browser specific prefixed versions...
}
.x-grid-item-selected .x-grid-cell:first-child {
background:
linear-gradient(top, rgb(119, 119, 119), transparent 6px),
linear-gradient(bottom, rgb(119, 119, 119), transparent 6px),
linear-gradient(left, rgb(119, 119, 119), transparent 6px);
// Browser specific prefixed versions...
}
.x-grid-item-selected .x-grid-cell:last-child {
background:
linear-gradient(top, rgb(119, 119, 119), transparent 6px),
linear-gradient(bottom, rgb(119, 119, 119), transparent 6px),
linear-gradient(right, rgb(119, 119, 119), transparent 6px);
// Browser specific prefixed versions...
}
Since this is still somewhat cumbersome, I'd really appreciate any more input to solve this in a more "elegant" way. 由于这仍然有些麻烦,因此我非常感谢您提供更多输入以更“优雅”的方式解决此问题。
Here's the working fiddle: https://fiddle.sencha.com/#fiddle/jrh 这是工作中的小提琴: https : //fiddle.sencha.com/#fiddle/jrh
Thanks & best regards 谢谢与问候
I just found another solution which actually fits my needs even better since the usage of the linear gradient
interfered with some other styles (eg background image of the first cell depending on content, ...). 我刚刚找到了另一个实际上更符合我的需求的解决方案,因为
linear gradient
的使用会干扰其他样式(例如,第一个单元格的背景图像取决于内容,...)。
This solution uses the pseudo element after
: 此解决方案使用伪元素
after
:
.x-grid-item-selected .x-grid-row:after {
content: '';
width: 100%;
height: 20px;
position: absolute;
left: 0;
box-shadow: 0 0 6px 2px rgb(119, 119, 119) inset;
}
Working fiddle: https://fiddle.sencha.com/#fiddle/jrm 工作小提琴: https : //fiddle.sencha.com/#fiddle/jrm
The only downside of this method is that I have to set a fixed height. 这种方法的唯一缺点是我必须设置一个固定的高度。 Again, I'd really appreciate if someone comes up with an even better way to do this.
再次,如果有人提出了更好的方法,我将非常感激。
Thanks & best regards 谢谢与问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.