Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jqGrid自定义格式化程序选项“;“不幸”;不起作用_Jqgrid_Formatter - Fatal编程技术网

jqGrid自定义格式化程序选项“;“不幸”;不起作用

jqGrid自定义格式化程序选项“;“不幸”;不起作用,jqgrid,formatter,Jqgrid,Formatter,jqGrid自定义格式化程序选项“unformat”在与函数一起提供时不起作用 我为这个选项提供函数。 本该工作,但不工作 使用unformat函数的主要目的是为sort函数(当您通过单击可排序列标题进行排序时)提供适当的值,该函数调用提供给colModel的unformat和formatter 这是我的代码(所有模块都包含在jQueryUI和jqgrid中) $(“#网格表”).jqGrid({ 数据类型:“本地”, colNames:['id','col1','col2','col3','

jqGrid自定义格式化程序选项“unformat”在与函数一起提供时不起作用

我为这个选项提供函数。 本该工作,但不工作

使用unformat函数的主要目的是为sort函数(当您通过单击可排序列标题进行排序时)提供适当的值,该函数调用提供给colModel的unformat和formatter

这是我的代码(所有模块都包含在jQueryUI和jqgrid中)


$(“#网格表”).jqGrid({
数据类型:“本地”,
colNames:['id','col1','col2','col3','col4'],
colModel:[{name:'id',index:'id',align:'left',width:'260px'},
{名称:'col1',索引:'col1',宽度:'170px'},
{名称:'col2',索引:'col2',宽度:'160px'},
{name:'col3',index:'col3',sorttype:'float',width:'110px',unformat:unformatterFunction,formatter:formatterFunction},
{名称:'col4',索引:'col4',排序类型:'float',宽度:'110px'}
],
阿尔特罗斯:是的,
标题:“测试数据”,
高度:“100%”,
自动宽度:正确,
shrinkToFit:是的,
});
函数未格式化函数(单元格值、选项、行对象){
如果(单元格值=“-”){
返回“0”;
}
返回单元格值;
}
函数formatterFunction(单元格值、选项、行对象){
如果(单元格值>15){
返回“-”;
}
返回单元格值;
}
我花了很多时间来跟踪对grid.base.js的调用,但没有找到任何方法可以访问jquery.fmatter.js,在jquery.fmatter.js中,每一行都会调用unformat函数。 我的疑问是排序时未调用unformat函数


我刚刚通过编辑确认,它不起作用,有些地方出了可怕的问题。我想不出有什么错误。它只是不调用colModel中指定的unformat函数。

如果需要自定义本地jqGrid的排序,使用自定义unformat是错误的。您需要的是使用
sorttype
作为函数。看一看包括演示或


sorttype
用作函数的最简单方法是从函数中返回转换后的数据,这些数据应用于在相应的比较操作中定义网格中的行顺序。

如果我想更改jqgrid的添加/编辑表单的css,该怎么办?
<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;
}