首页 新闻 搜索 专区 学院

如何把服务器端返回的json数据与extjs组件的渲染器函数(renderer)关联起来?

0
悬赏园豆:10 [已关闭问题] 关闭于 2013-10-17 23:09
 1 1.服务器端代码
 2 private <T extends IOrderSupported> String service(IOrderService<T> svc, T form, String error) throws Exception{
 3         SalesOrder var=OrderMngr.get(form.getOrdId());
 4         if(isAuthorized(var)){
 5             svc.service(var, form, request);
 6             json=JsonEncodeType.OBJECT.encode(var);
 7             return SUCCESS;
 8         }
 9         return error;
10     }

 

 1 2.  js代码
 2 //如果客户留言,则添加html代码;如果ppet留言,则不添加html代码
 3 function renderLastUpdate(val,x,store){ 
 4     var r=renderers.lastUpdate(val,x,store);
 5     if(store.data.userType=="C"){
 6         r+="<br/><img src='/img/new2_4.gif' title='New remark'/>";
 7     }
 8     
 9     return r;
10 }
11 var columns=[
12     {header: "流水号",dataIndex: "ordId",hidden:true},
13     {header: "订单号",dataIndex: "orderNo",renderer:renderCode,sortable:true},
14     {header: "国家",dataIndex: "nation"},
15     {header: "客户号",dataIndex: "custId",hidden:true},
16     {header: "客户",dataIndex: "custCode"},
17     {header: "客户名称",dataIndex: "custName",hidden:true},
18     {header: "客户类别",dataIndex: "custCate",hidden:true,renderer:renderCate},
19     {header: "货币",dataIndex: "currency"},
20     {header: "汇率",dataIndex: "crRate", renderer: Ext.util.Format.numberRenderer('0,0.00'),hidden:true},
21     {header: "日期格式",dataIndex: "dateFormat",hidden:true},
22     {header: "联系人",dataIndex: "linkman"},
23     {header: "状态",dataIndex: "status", renderer:renderState},
24     {header: "数量",dataIndex: "qty"},
25     {header: "净金额",dataIndex: "netAmount", renderer: Ext.util.Format.numberRenderer('0,0.00')},
26     {header: "附加费用",dataIndex: "additionalCost", renderer: Ext.util.Format.numberRenderer('0,0.00'),hidden:true},
27     {header: "运费",dataIndex: "deliCost", renderer: Ext.util.Format.numberRenderer('0,0.00'),hidden:true},
28     {header: "退款订单",dataIndex: "retOrderNo",hidden:true},
29     {header: "退款额",dataIndex: "retCharge", renderer: Ext.util.Format.numberRenderer('0,0.00'),hidden:true},
30     {header: "折扣",dataIndex: "discountAmount", renderer: Ext.util.Format.numberRenderer('0,0.00'),hidden:true},
31     {header: "总金额",dataIndex: "amount", renderer: Ext.util.Format.numberRenderer('0,0.00')},
32     {header: "备注",dataIndex: "remarks"},
33     {header: "订单日期",dataIndex: "orderDate", renderer: Ext.util.Format.dateRenderer('Y-m-d')},
34     {header: "下单者",dataIndex: "issuer"},
35     {header: "编辑者",dataIndex: "editor",hidden:true},
36     //{header: "最近更新",dataIndex: "lastUpdate", renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'), sortable:true},
37     {header: "最近更新",dataIndex: "lastUpdate", renderer: renderLastUpdate, sortable:true}, //1.表格面板的列:添加渲染器(函数)
38     {header: "删除",dataIndex: "ordId",hidden:true,renderer:renderers.erase}
39 ];

 

----------------- 
【问题】 
1.var实体对象和json对象的userType属性都有值; 
2.现在就是,属性的值《——》面板表格的值,这2者怎么关联起来呢?(渲染器函数不是自动执行的么) 






补充: 
1. 

function renderLastUpdate(val,x,store){   //【调试时】当java代码执行完毕,js里设置的断点都没有执行? 

  var r=renderers.lastUpdate(val,x,store); 

    if(store.data.userType=="C"){ 
        r+="<br/><img src='/img/new2_4.gif' title='New remark'/>"; 
    } 
    
    return r; 


2.如果只是单独设置js代码里的断点:当刷新后台相应的页面时,下面代码里的判断语句始终是假,也就是说服务器端的json对象的数据没有映射到store.data.userType,如何才能映射呢? 

function renderLastUpdate(val,x,store){ 
    var r=renderers.lastUpdate(val,x,store); 
    if(store.data.userType=="C"){ //1.执行到这一行的时候,判断语句始终为假 
        r+="<br/><img src='/img/new2_4.gif' title='New remark'/>"; 
    } 
    
    return r; 



(截图:面板的最后一列~) 

B_yellow的主页 B_yellow | 初学一级 | 园豆:5
提问于:2013-10-14 21:09
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册