在网格组合框中使用自定义 HTML
我需要设置网格在线编辑组合框来显示自定义 HTML。为了更具体,请查看此示例。单击Light
列中的任意单元格,打开组合框。我想在每个选项(“阴影”,“大部分阴影”,...)附近放置具有独特颜色的方框。
I need to set up grid enline-editing combo box to show custom HTML. To be more concrete, please, look at this sample. Click any cell in Light
column, open combobox. I want to place near every option ("Shade", "Mostly shady", ...) square box with unique color.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也遇到了同样的问题。当我尝试上面的解决方案时终于找到了答案(它也不起作用,但非常接近)。
结果列表项的类是 x-boundlist-item 而不是 x-combo-list-item。
如果您用该类标记您的 div 它将起作用。非常令人沮丧的是,Sencha 文档中组合框的 tpl 配置项下没有概述这一点,特别是当我能找到的所有示例都只显示项目的简单 div 时。我猜它曾经通过用 li 和类包装 tpl 配置中的任何内容来工作,但现在不再这样了。也就是说,这更通用,因为您可以通过省略这些项目的类来制作在下拉列表中不可选择的标题和行。
谢谢
I was having the same problem. Finally found the answer when I was trying the solution above (which doesn't work either but is really close).
Turns out that the class for the list items is x-boundlist-item not x-combo-list-item.
If you mark your div with that class it will work. Extremely frustrating that this isn't outlined in the Sencha docs under the tpl config item for combo boxes, especially when all of the examples I can find just show a simple div for the items. I'm guessing it used to work by wrapping whatever was in the tpl config with the li and the class but it doesn't anymore. That said this is more versatile since you can make headers and lines that aren't selectable in your dropdowns by leaving off the class for those items.
Thanks
为了使其全局工作(对于所有组合框),请使用以下覆盖:
For making it work globally (for all comboboxes), use the following override:
您需要做的只是修改
ComboBox
的tpl
配置选项,并使用您自己的自定义配置。然后,您可以创建一个新的 ComboBox 并将其用作列定义的编辑器
。以下是自定义 ComboBox 模板的示例:
然后,您可以在实例化编辑器时使用该 XTemlate;
What you need to do is just modify the
tpl
config option of theComboBox
, and use your own custom config. You can then create a new ComboBox and use that as theeditor
for the column definition.Here's a sample of a custom ComboBox template:
You can then use that XTemlate when you instantiate your editor;