- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
jqGrid 自定义格式化程序选项“unformat”在提供函数时不起作用。
我正在为此选项提供功能。
custom formatter example
假设工作,但它不工作。
我使用 unformat 函数的主要目的是为排序函数(当您通过单击可排序的列标题进行排序时)提供适当的值,该函数调用提供给 colModel 的 unformat 和格式化程序。
这是我的代码,(所有模块都包含在 jquery UI 和 jqgrid 中。)
<link href="../css/jquery-ui-1.8.11.custom.css" rel="stylesheet" type="text/css"/>
<link href="../css/ui.jqgrid.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../js/jquery-1.5.2.js"></script>
<script type="text/javascript" src="../js/jquery-ui-1.8.11.custom.min.js"></script>
<script type="text/javascript" src="../js/jquery.jqGrid.min.js"></script>
$("#GridTable").jqGrid({
datatype: "local",
colNames: ['id', 'col1', 'col2', 'col3', 'col4'],
colModel: [{name:'id',index:'id', align:'left', width:'260px'},
{name:'col1',index:'col1', width:'170px'},
{name:'col2',index:'col2', width:'160px'},
{name:'col3',index:'col3', sorttype:'float', width:'110px',unformat: unformatterFunction, formatter: formatterFunction },
{name:'col4',index:'col4', sorttype:'float', width:'110px'}
],
altRows: true,
caption: "Test Data",
height: '100%',
autowidth : true,
shrinkToFit: true,
});
function unformatterFunction(cellvalue, options, rowObject){
if(cellvalue=="-"){
return "0";
}
return cellvalue;
}
function formatterFunction(cellvalue, options, rowObject){
if(cellvalue > 15){
return "-";
}
return cellvalue;
}
最佳答案
如果您需要自定义对本地 jqGrid 的排序,则使用自定义 unformatter 是错误的方式。你需要的是使用sorttype
作为函数。看the old answer包括演示或this one .
使用 sorttype
的最简单方法因为该函数是从函数返回的转换数据,该数据应该用于定义在相应的比较操作中以定义网格中行的顺序。
关于jqGrid 自定义格式化程序选项 "unformat"不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5507171/
jqGrid 自定义格式化程序选项“unformat”在提供函数时不起作用。 我正在为此选项提供功能。 custom formatter example 假设工作,但它不工作。 我使用 unforma
看完this post在 GameDev.net 上,我决定看一看 C++ 标准。有几个 std::istream 函数被标准描述为“无格式输入函数”(如 tellg()、read() , ETC。)
如何使用批处理文件读取很长一行未格式化的 xml?我试图在每个“>”之后插入一个换行符。 问题是,我的批处理文件在找到“>”后跳到下一行。 并且由于这种行为,只显示了我的 xml 文件的第一个标记(只
我在理解字符串的 format() 方法的工作方式时遇到了一些麻烦。 假设我设置了一个带有关键字参数的字符串变量: s = '{hello} {person_name}' 我可以将此值分配给另一个变量
我想弄清楚 VS 代码是什么 html.format.unformatted设置可以,但我不能。 我找到了 this issue和 this issue在 GitHub 中,但它什么也没解释。 有人可
我希望在字符串中找到子字符串(从数组中),然后将其替换为标题等于子字符串的下拉框。 该字符串来自用户输入,子字符串是从我的工作代码中的数据库中提取的。 我根据 DavidTonarini 在这个问题中
我已经玩了一段时间了,但我得到的最接近的是一个按钮,可以打开 Paste Special对话框,需要再单击几下鼠标才能将剪贴板的内容粘贴为无格式文本。 我经常做一个 copy-paste从一个网站到一
我使用以下代码编写了这个非常简单的 5 个数字列表,并在 64 位 Linux 计算机上使用 gfortran 编译: integer, parameter :: binary64 = select
我是一名优秀的程序员,十分优秀!