簡體   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