是否可以阻止 jqGrid 行被选择和/或突出显示?

发布于 2024-08-19 20:40:07 字数 497 浏览 7 评论 0原文

我查看了 文档 但我无法寻找答案。有没有办法防止行在选择时突出显示?那甚至是一种完全停止选择行的方法。我喜欢“hoverrows: true”选项,但理想情况下我想阻止单击时选择一行。

谢谢,

更新: 我已经能够“粗暴地”实施一些似乎是临时修复的东西。我根本不喜欢它,并且理想地希望有一个更好的解决方案,如果有的话......

我发现,如果我

onSelectRow: function(rowid, status) {
    $('#'+rowid).removeClass('ui-state-highlight');
}

在实例化 jqGrid 时传递该选项,我可以在添加它时删除突出显示。

还有另一种更理想的方法吗?

I've looked at the documentation but I've been unable to find an answer. Is there a way to prevent a row from being highlighted when selected? That or even a way to stop the row being selected at all. I like the "hoverrows: true" option, but ideally I would like to stop a row from being selected on-click.

Thanks,

Update:
I've been able to "hackily" implement something which seems to be an interim fix. I don't really like it at all and would idealy like a better solution, if there is one...

I have found that if I pass the option

onSelectRow: function(rowid, status) {
    $('#'+rowid).removeClass('ui-state-highlight');
}

when I instantiate the jqGrid, I can strip the highlight when it is added.

Is there another, more ideal, way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

清眉祭 2024-08-26 20:40:07

使用以下代码:

beforeSelectRow: function(rowid, e) {
    return false;
}

Use the following code:

beforeSelectRow: function(rowid, e) {
    return false;
}
三岁铭 2024-08-26 20:40:07

如果您像我一样,拥有无数个 jqGrid,并且不想为每个 jqGrid 覆盖 onSelectRow,那么这里有一个 Reigel 解决方案的全局版本,对我来说效果很好:

jQuery.extend(jQuery.jgrid.defaults, {
    onSelectRow: function(rowid, e) {
        $('#'+rowid).parents('table').resetSelection();
    }
});

If you, like me, have a gazillion jqGrids and don't want to override onSelectRow for every single one, here's a global version of Reigel's solution that worked nicely for me:

jQuery.extend(jQuery.jgrid.defaults, {
    onSelectRow: function(rowid, e) {
        $('#'+rowid).parents('table').resetSelection();
    }
});
无边思念无边月 2024-08-26 20:40:07

尝试:

onSelectRow: function(rowid, status) {
    $("#grid_id").resetSelection(); //Resets (unselects) the selected row(s). Also works in multiselect mode.
}

您可以在此处阅读文档。希望它能帮助你...

try:

onSelectRow: function(rowid, status) {
    $("#grid_id").resetSelection(); //Resets (unselects) the selected row(s). Also works in multiselect mode.
}

you can read documentations here. Hope it helps you...

世界和平 2024-08-26 20:40:07

我想你可以直接在 CSS 中解决这个问题。只需覆盖特定表的 ui-state-highlight 值即可。

#table_id tr.ui-state-highlight {
  border: inherit !important;
  background: inherit !important;
  color: inherit !important;
}

#table_id tr.ui-state-highlight a {
  color: inherit !important;
}

#table_id tr.ui-state-highlight .ui-icon {
  background-image: inherit !important;
}

我使用值 inherit 作为示例 - 您可能需要从 theme.css 复制一些值才能完成此操作。

I suppose you could address this in the CSS directly. Just override the values for ui-state-highlight for your specific table

#table_id tr.ui-state-highlight {
  border: inherit !important;
  background: inherit !important;
  color: inherit !important;
}

#table_id tr.ui-state-highlight a {
  color: inherit !important;
}

#table_id tr.ui-state-highlight .ui-icon {
  background-image: inherit !important;
}

I used the value inherit just as an example - you will likely need to copy some values from your theme.css to make this work.

苦笑流年记忆 2024-08-26 20:40:07

是的,使用 rowattr 回调:

rowattr: function (rowData,currentObj,rowId) {
    if (rowData.SomeField=="SomeValue") { 
        return {"class": "ui-state-disabled"};
    }
},

这也会使该行变灰并禁用选择。

Yes, use the rowattr callback:

rowattr: function (rowData,currentObj,rowId) {
    if (rowData.SomeField=="SomeValue") { 
        return {"class": "ui-state-disabled"};
    }
},

This also grays out the row and disables the selection.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文