开发者社区> 问答> 正文

jqGrid 如何获取格式前的数据

我用jqGrid画了一个表格,里面有一列的数据被我格式了。现在我想在选择表格中某一行的时候读取被格式那一列的为格式之前的数据,要怎么写呢?

我的代码:

var mystr="<?xml version='1.0' encoding='UTF-8'?><Service><Result><DTO><ProductList><entry><productCode>CODE1</productCode><productName>Name 1</productName></entry><entry><productCode>CODE2</productCode><productName>Name 2</productName></entry></ProductList></DTO></Result></Service>";

jQuery().ready(function (){
                jQuery("#list1").jqGrid({
                 datatype: 'xmlstring',
                    datastr: mystr,
                    colNames:['Product Code', 'Product Name'],
                    colModel:[
                     {name:'id',index:'id', width:75, formatter:formateProduct, frozen :true,xmlmap:"productCode" },
                     {name:'invdate',index:'invdate', width:90, xmlmap:"productName"},
                    ],
             xmlReader: { 
             root:"Service>Result>DTO>ProductList", 
             row:"entry",
             repeatitems:false,
             id : "asin"},
                    Height: 800,
                    width:  1000,
                    autowidth: true,
                    //rowList:[10,20,30],
                    pager: jQuery('#pager1'),
                    sortname : 'id',
                    viewrecords : 'true',
                    sortorder: 'desc',
                    caption  : "XML Example",
                    onSelectRow: function(rowid) {

                     },
                    loadonce:true,
           scroll:1,
           rowNum:20
           //gridview:true
                });
                jQuery("#list1").jqGrid('navGrid','#pager1',{edit:false,add:false,del:false});
            });
            function formateProduct( cellvalue, options, rowObject )
            {
           return "Test" ;           }

展开
收起
a123456678 2016-07-06 10:36:54 2053 0
1 条回答
写回答
取消 提交回答
  • unformat应该是你想要的,unformat与formatter都是在colModel中定义的。

    2019-07-17 19:51:55
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载

相关实验场景

更多