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 }
cellvalue:要被格式化的值
options:对数据进行格式化时的参数设置,格式为:
{ rowId: rid, colModel: cm}
rowObject:行数据
数据的反格式化跟格式化用法相似.
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("$",""); }
表格中数据实际值为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>
具体使用:
jQuery("#grid_id").jqGrid({ ... colModel: [ ... {name:'price', index:'price', width:60, align:"center", editable: true, formatter:currencyFmatter}, ... ] ... })
相关推荐
jquery.jqGrid-4.5.2.zip 官方资源文件
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.1.1.zipjquery.jqGrid-4.1.1.zipjquery.jqGrid-4.1.1.zip
jqGrid-master最新版,从英文站点下载而来,方便各位下载
jquery.jqGrid-4.4.3,用于web页面的列表分页显示
jqGrid 是一个用来显示网格数据的jQuery插件,文档比较全面,附带中文版本。 主要特点: -Full control with JavaScript API -Data returned from the server is XML -Simple configuration -Ability to load big ...
jqGrid-wiki版手册
jquery.jqGrid-4.3.2.zip
jquery.jqGrid-4.4.4.zip
jquery.jqGrid-3.5.3 最新版本 jqGrid是一個jQuery的plugin,提供grid操作介面,並支援經Ajax連結伺服器上的資料源。jqGrid在共同的基礎結構上,提供數種操作模式,分別包裝於不同的檔案之中。除了共用的數個檔案...
jqGrid-3.2 jqgriddocs.pdf jquery.jqGrid.js
jquery grid 表单插件,去官网下不到吗,还好有人做了备份,多谢多谢!本着分享的精神,同时也做一个备份,把4.5.4的包放到网上!
jquery.jqGrid-4.4.5,最新版的jqgrid,支持jquery ui皮肤
jquery.jqGrid-4.3.1+jquery-ui-1.8.17.rar
非常好用的表格插件,还有bootstrap风格,支持国际化。
jquery.jqGrid-4.3.1.zip