jqgrid 版本 4-4-3 中可以自定义 asc desc

It is possible to customise asc desc in jqgrid version 4-4-3

是否可以在将数据加载到 jqgrid 时仅显示 asc 或 desc 图标? 我如何自定义图标的颜色?

如果我正确理解问题,您可以使用网格选项 viewsortcols。您可以在 version here

的文档中找到更多内容

您遇到的主要问题是:您使用的是非常旧的 jqGrid 4.4.3 版本,已经有将近 5 年的历史了。旧的 jqGrid 不允许显示 只有一个 排序图标。此外,它只允许使用旧的 jQuery UI 图标,它使用 PNG 图像作为图标。无法更改 png 图像的颜色 对于不同的图标 因为每个图标都是一个图像的一部分,如下图:

您可以看到,Redmond 团队使用的上图对所有 图标使用了蓝色。它使实现您的要求变得更加复杂。

我建议您考虑升级到 free jqGrid 的当前版本 (4.15.1) - jqGrid 的分支,我从 2014 年底开始开发。该分支与 4.4 兼容.3.

免费的 jqGrid 支持许多新选项,例如您需要的选项 showOneSortIcon: true。此外,它允许包含 Font Awesome 4.x font-awesome.min.css and to add iconSet: "fontAwesome" option to replace all jQuery UI icons to vector-based Font Awesome icons. See here an example of usage. As the result you can easy specify any color for any icon. For example, the demo https://jsfiddle.net/OlegKi/2cgyL4qx/ 的 CSS 使用以下 CSS 规则结合 showOneSortIcon: trueiconSet: "fontAwesome" 选项:

.ui-jqgrid .s-ico > .ui-icon-desc.fa {
    color: green;
    top: -0.3em;
}
.ui-jqgrid .s-ico > .ui-icon-asc.fa {
    color: red;
    top: 0.1em;
}

结果 asc/desc 图标如下图所示

免费的 jqGrid 包含许多其他选项,允许自定义排序图标(请参阅 here). For example, one can full overwrite the standard icons to your custom icons and uses the icons, for example, depend on the type of data in the corresponding column. You can try one more demo https://jsfiddle.net/OlegKi/1c7rxfLn/ 并检查不同列中的排序图标。您将看到 3 组不同的图标:数字、字母和其他数据类型。排序图标如下图所示: