EXTJS 单击时更改网格单元背景颜色
我的代码的一部分
xtype: 'grid',
width: 500,
store: store6,
columns:[{
text:'Market',
sortable: false,
width:145,
dataIndex: 'market
}]
我尝试使用侦听器(我认为我没有正确执行),并且由于每个单元格没有 id 标签,我不知道 click 是否可以在这里工作。
使用案例 1. 用户点击单元格 2. 代码将单元格变成绿色 3. 用户点击同一个单元格 4. 代码将单元格变成白色 每个单元格的颜色完全取决于用户。
这都是客户端开发,我还没有开始任何服务器端(PHP)开发。我在 Stack 上搜索了一下,但没有找到有效的解决方案。任何帮助或评论都会很有帮助。
Portion of my code
xtype: 'grid',
width: 500,
store: store6,
columns:[{
text:'Market',
sortable: false,
width:145,
dataIndex: 'market
}]
I've tried using listeners(which I think i didn't do correctly) and I don't know if click will work here due to each cell not having an id tag.
USE CASE
1. User clicks cell
2. Code turns cell green
3. User clicks the same cell
4. Code turns cell white
The color to each cell depends solely from the user.
This is all client side development which I haven't started any server side (PHP) development yet. I've searched on Stack for a bit and I haven't found a solution that works. Any help or comments would really help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这正是我正在寻找的。感谢 InnerJL 为我指明了正确的方向。我需要它来点击。白色和绿色之间交替。解决方案贴在下面
This is exactly what I'm looking for. Thank InnerJL for directing me in the right direction. I needed it to work for click. Alternating between white and green. Solution is posted below
我做了类似的事情,我们使用自定义 列渲染器。
这是示例代码:
请注意,您可以修改元数据中的 css 属性 - 您可以设置单元格的颜色。例如,每次点击,您都会增加记录的一些内部计数器。然后,渲染器根据此计数器在单元格上添加不同的 css 类。
希望这有帮助!
I did similar things and we used custom column renderer.
Here it's code for example:
Note that you could modify the css property in metadata - you could setup color of the cell. For example on each click you increment some internal counter of your record. Then you renderer depending on this counter adds different css classes on the cell.
Hope this helps!
我已经尝试过 statusRenederer 但没有任何反应,但我从下面的代码中得到了一些响应。
问题是我实际上可以获取 id。而且 getCSS 也有一些问题。除非有一个我不能的 ExtJS 类我可以在 sencha.com 上查找 ID,但无法更改 CSS。
I've tried the statusRenederer and nothing happens but I"m getting some response from the code below.
The thing is that I can actually get the id. Also getCSS also had some problems. Unless there is an ExtJS class that I can't look up on sencha.com. I can get the ID just fine but no way to change the CSS.
成功!!!!
我选择了 DOM 编程,而不是查看 ExtJS,这才是我真正想要的,但这可以完成工作。我所要做的就是在绿色和白色之间切换。
SUCCESS!!!!
I went to DOM programming instead of looking through ExtJS which is what I really would have preferred but this gets the job done. All I have to do is toggle between green and white.