xwb_mountain 2015-04-24 08:39 采纳率: 0%
浏览 2008

JqueryEasyUI datagrid 获取不了Struts.xml解析的JSON数据

resultList [{total=10, rows=[{code=150302000009, name=葡萄, id=60, pzid=50, cydw=宾川金玉果品有限责任公司, cd=敖汝龙, cydate=2015-03-02, nr=, statue=已检测, addtime=2015-03-02 15:35:09.0}, {code=141125000008, name=葡萄, id=51, pzid=50, cydw=宾川县金土鲜果产销专业合作社, cd=敖宗银, cydate=2014-11-25, nr=45, statue=已检测, addtime=2014-11-25 10:40:58.0}, {code=141103000007, name=大蒜, id=49, pzid=144, cydw=宾川县汇丰农副产品营销专业合作社, cd=余利祥, cydate=2014-11-03, nr=, statue=已检测, addtime=2014-11-03 08:58:07.0}, {code=141103000006, name=大蒜, id=48, pzid=145, cydw=华祥农副产品加工厂, cd=周家文, cydate=2014-11-03, nr=sd, statue=未检测, addtime=2014-11-21 15:38:07.0}, {code=141031000005, name=葡萄, id=47, pzid=52, cydw=宾川县汇丰农副产品营销专业合作社, cd=张存道, cydate=2014-10-31, nr=, statue=已检测, addtime=2014-10-31 15:58:52.0}, {code=141029000004, name=葡萄, id=46, pzid=50, cydw=宾川县汇丰农副产品营销专业合作社, cd=杜跃平, cydate=2014-10-29, nr=农药, statue=已检测, addtime=2014-10-29 16:11:12.0}, {code=141017000003, name=黄瓜, id=45, pzid=160, cydw=宾川县云福公司, cd=敖汝龙, cydate=2014-10-17, nr=农药残留, statue=已检测, addtime=2014-10-17 13:55:10.0}, {code=141017000002, name=柿子, id=44, pzid=114, cydw=宾川县云福公司, cd=张丕生, cydate=2014-10-17, nr=农药检测, statue=已检测, addtime=2014-10-17 13:44:23.0}, {code=141017000001, name=葡萄, id=43, pzid=50, cydw=宾川宽恳农副产品有限公司, cd=李宝林, cydate=2014-10-17, nr=农药检测, statue=已检测, addtime=2014-10-17 13:40:23.0}, {code=121017000001, name=1210宽恳红葡萄, id=42, pzid=50, cydw=宾川宽恳农副产品有限公司, cd=李宝林, cydate=2012-10-17, nr=农药残留, statue=已检测, addtime=2012-10-17 11:58:31.0}]}]
图片说明

前台JSP datagrid代码

 var pzs = ${pzs};
    function productFormatter(value){
        var pzdata =  JSON.parse('${pzs}');
        for(var i=0; i<pzdata.length; i++){
            if (pzdata[i].pzid == value) {
                return pzdata[i].pzname;
            }
        }
        return value;
    }
    var lastIndex = undefined;
    $("#dg").datagrid({    
        url:'jcypgl_getItemList.action',
        toolbar:[{  
            text:'新增行',  
            iconCls: 'icon-add',  
            handler: function(){
                if(lastIndex!=undefined){
                    $("#dg").datagrid("endEdit",lastIndex);
                }
                //if(lastIndex==undefined){
                //}
                $("#dg").datagrid("insertRow",{index:0,row:{
                }});
                //$("#dg").datagrid("beginEdit",0);
                //lastIndex = 0;
                $('#dg').datagrid('selectRow', 0);
            }  
        },'-',{  
            text:'删除行',  
            iconCls: 'icon-remove',  
            handler: function(){
                var row = $('#dg').datagrid('getSelected');
                if (row){
                    var index = $('#dg').datagrid('getRowIndex', row);
                    $('#dg').datagrid('deleteRow', index);
                }
            }  
        },'-',{  
            text:'编辑',  
            iconCls: 'icon-edit',  
            handler: function(){ 
                alert("ssss");
                $("#dg").datagrid("loadData",lodata);
            }  
        }],
        frozenColumns:[[
                        //{ field: 'ck', checkbox: true },
                        {field:'code',title:'样品编号',width:100}
                       ]],
        fitColumns:false,
        iconCls:'icon-edit',
        singleSelect:true,
        showFooter:true,
        striped:true,
        nowrap:true,
        columns:[[
            {field:'id',hidden:true,width:100,editor:'text'},
            {field:'name',title:'样品名称',width:100,editor:'text'  },
            {field:'pzid',title:'样品品种',width:100,formatter:productFormatter,
                editor:{
                    type:'combobox',
                    options:{
                        valueField:'pzid',
                        textField:'pzname',
                        data:pzs
                        //required:true
                }
            } },
            {field:'cydw',title:'采样单位',width:100,editor:'text'  },
            {field:'cd',title:'产地',width:100,editor:'text'  },
            {field:'cydate',title:'采样日期',width:100,editor:'text' },
            {field:'nr',title:'内容',width:100,
                editor:'text'   
            },
            {field:'statue',title:'状态',width:100,editor:'text'  },
            {field:'addtime',title:'添加时间',width:100,editor:{
                type:'datebox',
                options:{

                }
            }}
        ]]
    ,
    onClickRow:function(rowIndex){
        //alert("lastIndex  "+lastIndex);
        if (lastIndex != rowIndex){
            $('#dg').datagrid('endEdit', lastIndex);
        }
    },
    onDblClickRow:function(rowIndex, rowData){
        //alert("lastIndex  "+lastIndex+"  rowIndex"+rowIndex);
        if (lastIndex != rowIndex){
            $('#dg').datagrid('endEdit', lastIndex);
            $('#dg').datagrid('beginEdit', rowIndex);
        }
        lastIndex = rowIndex;
    },
    onAfterEdit:function(rowIndex,rowData,changes){
        alert(changes);
        //alert(JSON.stringify(rowData));
        var rowdta =  JSON.stringify(rowData);
            $.ajax({
            type:"post",
            url:"jcypgl_testEdit.action",
            data:{  
                "rowData":rowdta
            },
            dataType:"json",
            success:function(data){

                }
            });

    },
    // pageNumber:1,
    //pageSize:5,
    //pageList:[5,10,15,20],
    //pagination:true
    });
});


function doSearch(){
    $('#dg').datagrid('load',{
        itemid: $('#itemid').val(),
        productid: $('#productid').val()
    });
}
  • 写回答

3条回答 默认 最新

  • lingfengzx 2015-04-24 08:55
    关注

    json格式不都是{key1:value1,key2:value2}这种格式吗

    为什么你的是{key1=value1,key2=value2}

    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题