繁体   English   中英

从客户端和服务器渲染时,Jsreport显示不同的结果

[英]Jsreport shows different result when rendering from client and server

我有一个名为A的模板,一个测试Json存储在服务器中。 使用jsreport的常规设置来呈现PDF在服务器中的工作奇迹。

现在,我想使用Jsreport_client.js进行渲染。 我对其他服务器执行AJAX调用getJSON并使用jsclient进行渲染。 但是现在数据无法正确发送/处理。 位于JSON对象根附近的密钥是正确的,而其余的则不是。 请注意,相同的JSON可以正确在服务器上呈现

编辑:下面是电话

$.getJSON(AJAXurl).success(function (people) {
 jsreport.serverUrl = 'http://localhost:5488';
 var request = {
   template: { 
     shortid:"rJPUhdmv"
   },
   data: people
  };                                   
  jsreport.render('_blank', request);
})

以下是返回的请求结构

{
  "responseHeader":{
    "status":0,
    "params":{
      "fq":"{!frange l=0.80 }query($q)",
      "q":"{!percentage}etco~",
      "group.field":"ent_id"
}},

  "grouped":{
    "ent_id":{
      "ngroups":3,
      "groups":[{
          "groupValue":"214493",
          "doclist":{"numFound":1,"docs":[
              {

                "add_city":"London",
                "add_street":"Devonshire Street",
                "nam_comp_name":"ETCO INTERNATIONAL COMMODITIES LTD.",
                "add_country":"GB",             
                "add_id":"668638",
                "score":1.0}]
          }},OTHER GROUP.....]}}},

  "highlighting":{
    "C":{
      "nam_comp_name":["<span class=\"highlight\">ETO</span>"]}
}}

下面是服务器中的处理程序

// Can not read any parameters
 </thead>
          {{#each grouped.ent_id.groups}}
          </tr>
          <td>{{offsetIndex @index}}</td>
          {{#each doclist.docs}}
          <td>{{this.nam_comp_name}}</td>
          <td>{{convertScore this.score}}</td>
           <td>{{this.add_country}} {{this.add_city}} {{this.add_street}}</td>
            <td>{{lis_name}}</td>
          {{/each}}                   
          </tr>
           {{/each}}

另一个具有正确和不正确/不可读数据的处理程序

 {{#responseHeader.params}}
  <tr>
    <th>Search term</th>
    <td>{{sanitizeQuery this.q}}</td>    // Read correctly
  </tr>
  <tr>
    <th>Sanction List: </th>
    <td>{{sanitizeQuery this.fq.[0]}}</td> // Incorrectly
  </tr>
  <tr>
    <th>Countries:</th>
    <td>{{sanitizeQuery this.fq.[1]}}</td> // Incorrectly
  </tr>
   {{/responseHeader.params}}
    <tr>
    <th>Search by:</th>
    <td>"Method of searching"</td> // Incorrectly
   </tr>
    <tr>
    <th>Found total:</th>
    <td>{{grouped.ent_id.ngroups}}</td> // Read correctly

帮手

function offsetIndex(index) {
    return index+1;
}

function convertScore(score) {
    a = parseFloat(score);
    return a*100;
}
function sanitizeQuery(query) {
    a =query
        .replace(/{+.*?}+/g, "")
        .replace(/\[\[|\]\]/g, "")
        .replace(/<.*?>/g, "")
        .replace(/add_country:/,"")
        .replace(/program_number:/,"")
        .replace(/~/,"");
    return a;
}

这是jsreport浏览器客户端中的数组序列化错误。 现在已修复。

请更新到jsreport-browser-client-dist@1.0.2或更新整个jsreport,您也可以在jsreport@1.0.9中找到它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM