2017-10-13 60 views
0

我是serviceNow的新手,并尝试创建一个Accordian小工具来显示由ProjectName分组的表中的信息。ServiceNow服务门户AngularJS Accordian小工具不工作

当我在Widget Editor中运行这段代码时,手风琴出现了,但没有填充{{mytable.id}},只显示了项目名称。

此外,只有顶级项目名称是折叠/开放,我认为这归因于非唯一ID。

我不知道如何解决这个问题。

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
<div class="panel-group" id="accordian"> 
 
    <div class="panel panel-{{mytable.id}}" ng-repeat="mytable in data.mytables"> 
 
    <div class="panel-heading" role="tab" id="heading_{{::mytable.pid}}"> 
 
     <div class="panel-group" id="accordian"> 
 
     <div class="panel panel-{{mytable.id}}" ng-repeat="mytable in data.mytables"> 
 
      <div class="panel-heading" role="tab" id="heading_{{::mytable.pid}}"> 
 
      <span class=”panel-title”> 
 
\t \t <a role=”button” data-toggle=”collapse” href=”#collapse_{{mytable.id}}” aria-expanded=”true” aria-controls=”collapse_{{::mytable.id}}”> 
 
\t \t \t <i class=”fa fa-chevron-down”></i>{{::mytable.project_name}} <span class=”badge”>{{::mytable.count}}</span> 
 
      </a> 
 
      </span> 
 
      </div> 
 
      <div id=”#collapse_{{::mytable.id}}” class=”panel-collapse collapse” role=”tabpanel” aria-labelledby=”heading_{{::mytable.id}}”> 
 
      <div class=”panel-body”> 
 
       <table class=”table”> 
 
       <thead> 
 
        <tr> 
 
        <th>Month</th> 
 
        <th>Year</th> 
 
        <th>PDF</th> 
 
        <th>XLS</th> 
 
        <th> 
 
       </thead> 
 
       <tbody> 
 
        <tr> 
 
        <td>{{::mytable.invoice_month}}</td> 
 
        <td>{{::mytable.invoice_year}}</td> 
 
        <td>{{::mytable.pdf}}</td> 
 
        <td>{{::mytable.xls}}</td> 
 
        </tr> 
 
       </tbody> 
 
       </table> 
 
      </div> 
 
      </div> 
 
     </div>

/*Client Script*/ 
 
function($scope){ 
 
    var c = this; 
 
} 
 

 

 
/*Service Script*/ 
 
(function() { 
 
    data.mytables = []; 
 
    
 
    var gr = new GlideAggregate('x_project_table'); 
 
    gr.addActiveQuery(); 
 
    gr.groupBy('project_name'); 
 
    gr.query(); 
 
    
 
    while(gr.next()){ 
 
     var mytable = {}; 
 
     mytable.project_name = gr.getDisplayValue('project_name'); 
 
     mytable.invoice_month = gr.getDisplayValue('invoice_month'); 
 
     mytable.invoice_year = gr.getDisplayValue('invoice_year'); 
 
     mytable.pdf = gr.getDisplayValue('pdf'); 
 
     mytable.xls = gr.getDisplayValue('xls'); 
 
     data.mytables.push(mytable); 
 
    } 
 
})(); 
 
    

回答

0

{{mytable.id}}没有填充,因为你没有在你的服务器脚本指定。

您需要类似mytable.id= gr.getValue('sys_id');