编辑后的 SlickGrid onCellChange 如示例 7 所示
如果我将以下代码添加到 SlickGrid 示例 7:
grid.onCellChange.subscribe(function(e,args)
{
alert("here");
});
如果我更新文本字段“标题”,则会出现警报。当我更新“优先级”字段时,它不会出现,该字段用于演示单击以切换值。使用此代码捕获点击。
grid.onClick.subscribe(function(e) {
var cell = grid.getCellFromEvent(e);
if (columns[cell.cell].id == "priority") {
var states = { "Low": "Medium", "Medium": "High", "High": "Low" };
data[cell.row].priority = states[data[cell.row].priority];
grid.updateRow(cell.row);
e.stopPropagation();
}
});
问题: 当“优先级”值更改时如何触发 onCellChange?
感谢任何可以提供帮助的人。 约翰.
If I add the following code to SlickGrid example 7:
grid.onCellChange.subscribe(function(e,args)
{
alert("here");
});
The alert appears if I update the text field, 'Title'. It does not when I update the 'Priority' field, which is being used to demonstrate click to toggle values. Clicks are captured with this code.
grid.onClick.subscribe(function(e) {
var cell = grid.getCellFromEvent(e);
if (columns[cell.cell].id == "priority") {
var states = { "Low": "Medium", "Medium": "High", "High": "Low" };
data[cell.row].priority = states[data[cell.row].priority];
grid.updateRow(cell.row);
e.stopPropagation();
}
});
Question:
How do I trigger onCellChange when the 'Priority' value changes?
Thank you to anyone who can help.
John.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对我来说非常有意义。
仅当操作在网格内启动时,网格才会引发该事件。
在第二个示例中,您通过拦截特定的单击事件直接对数据源进行更改。
Makes perfect sense to me.
The event is raised by the grid only if the action was initiated within the grid.
In your second example, you are making the change yourself directly against the data source by intercepting specific click events.
仅将 JQuery 与
$(#priority).change
选择器一起使用怎么样?因此,它的外观如下(或类似的内容):
您可能希望将其更改为使用类而不是 id,因为每个 DOM id 应该在每个页面上保持唯一。
How about just using JQuery with the
$(#priority).change
selector?So here is how it would look (or something similar):
You probably want to change it to use a class instead of an id though, as each DOM id is supposed to remain unique per page.