<script>
jQuery("#grid_id").jqGrid({
...
colModel: [
...
{name:'price', index:'price', width:60, align:"center", editable: true, formatter:currencyFmatter},
...
]
...
});
function currencyFmatter (cellvalue, options, rowObject)
{
// do something here
return new_format_value
}
</script>
定义的参数
function myformatter ( cellvalue, options, rowObject )
{
// format the cellvalue to new format
return new_formated_cellvalue;
}
cellvalue:要被格式化的值
options:对数据进行格式化时的参数设置,格式为:
{ rowId: rid, colModel: cm}
rowObject:行数据
数据的反格式化跟格式化用法相似。
<script>
jQuery("#grid_id").jqGrid({
...
colModel: [
...
{name:'price', index:'price', width:60, align:"center", editable: true, formatter:currencyFmatter, unformat:unformatCurrency},
...
]
...
});
function currencyFmatter (cellvalue, options, rowObject)
{
return "$"+cellvalue;
}
function unformatCurrency (cellvalue, options)
{
return cellvalue.replace("$","");
}
</script>
表格中数据实际值为123.00,但是显示的是$123.00; 我们使用getRowData ,getCell 方法取得的值是123.00。
创建通用的格式化函数
定义如下:
<script type="text/javascript">
jQuery.extend($.fn.fmatter , {
currencyFmatter : function(cellvalue, options, rowdata) {
return "$"+cellvalue;
}
});
jQuery.extend($.fn.fmatter.currencyFmatter , {
unformat : function(cellvalue, options) {
return cellvalue.replace("$","");
}
});
</script>
具体使用:
<script>
jQuery("#grid_id").jqGrid({
...
colModel: [
...
{name:'price', index:'price', width:60, align:"center", editable: true, formatter:currencyFmatter},
...
]
...
});
分享到:
相关推荐
Jqgrid demo-史上最强大,没有之一, 为了大家能够更好的学习和使用Jqgrid网格插件,我决定用Strtus2+Spring+hibernate+Jquery+Jqgrid实现一个Jqgrid网格插件的demo。当然官方网站上面已经有了PHP版本和ASP.NET版本...
jquery.jqGrid-4.4.3,用于web页面的列表分页显示
jqgrid方法-中文 (2).docxjqgrid方法-中文 (2).docx
jqGrid是一个非常好用的免费开源Grid组件,功能强大,适用于各种表格操作,数据管理。作为jquery插件,jqGrid使用方便,简介,美观。
jqGrid 学习 自定义格式化类型 19 jqGrid 学习 格式化 21 jqGrid 学习 自定义按钮 26 jqGrid 学习 翻页(2) 28 jqGrid 学习 翻页 33 jqGrid 学习 配置 json 35 jqGrid 学习 方法 37 jqGrid 学习 事件 45 jqGrid ...
jquery.jqGrid-3.8.2.zipjquery.jqGrid-3.8.2.zipjquery.jqGrid-3.8.2.zipjquery.jqGrid-3.8.2.zipjquery.jqGrid-3.8.2.zipjquery.jqGrid-3.8.2.zip
jquery.jqGrid-4.5.2.zip 官方资源文件
jquery.jqGrid-4.8.2(jquery表格插件).zip----------jqGrid4.8.2包,官网下载的,原封不动的在这里。 jqgrid_demo40-----可用的-使用方法请查看README文件. jqgrid_3.6.5_API_en.chm------附加放在这里的其它资料...
jqgrid jquey 样式 让表格变得更漂亮
jqgrid自定义按钮,jqgrid自定义按钮,jqgrid自定义按钮
jquery.jqGrid-4.3.1+jquery-ui-1.8.17.rar
jqGrid 是一个用来显示网格数据的jQuery插件,文档比较全面,附带中文版本。 主要特点: -Full control with JavaScript API -Data returned from the server is XML -Simple configuration -Ability to load big ...
NULL 博文链接:https://only-xxp.iteye.com/blog/768029
jquery.jqGrid-4.1.1.zipjquery.jqGrid-4.1.1.zipjquery.jqGrid-4.1.1.zip
jqGrid-wiki版手册
jqGrid-master最新版,从英文站点下载而来,方便各位下载
jqGrid-3.2 jqgriddocs.pdf jquery.jqGrid.js
jquery.jqGrid-4.3.2.zip
jquery.jqGrid-4.5.4 样式表css: jquery-ui-custom.css ui.jqgrid.css 图片png: ui-bg_flat_0_aaaaaa_40x100.png ui-bg_flat_55_fbec88_40x100.png ui-bg_glass_75_d0e5f5_1x400.png ui-bg_glass_85_dfeffc_1x400...