2017-10-13 1 views
0

Ich bin neu zu ServiceNow und versuche, ein Accordian Widget zu erstellen, um Informationen in einer nach ProjectName gruppierten Tabelle anzuzeigen.ServiceNow Service Portal AngularJS Accordian Widget funktioniert nicht

Wenn ich diesen Code im Widget-Editor starte, erscheint der Akkordeon, aber {{mytable.id}} füllt nicht und nur die Projektnamen werden angezeigt.

Auch nur der oberste Projektname kollabiert/öffnet, was meiner Meinung nach der nicht eindeutigen ID zugeordnet wird.

Ich weiß nicht, wie das zu beheben ist.

<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); 
 
    } 
 
})(); 
 
    

Antwort

0

{{mytable.id}} ist bevölkern nicht, weil Sie nicht in Ihrem Server-Skript angegeben haben.

Sie benötigen etwas wie mytable.id= gr.getValue('sys_id');

Verwandte Themen