2017-10-13 7 views
0

Je suis nouveau à serviceNow et essayer de créer un Widget Accordian pour afficher des informations dans une table regroupées par ProjectName.ServiceNow Portail AngularJS Accordian Widget ne fonctionne pas

Lorsque j'exécute ce code dans l'éditeur de widget, l'accordéon s'affiche mais {{mytable.id}} ne s'affiche pas et seuls les noms de projet s'affichent.

En outre, seul le nom de projet supérieur est collapse/ouverture qui, je pense, est attribué à l'ID non unique.

Je ne sais pas comment résoudre ce problème.

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

Répondre

0

{{mytable.id}} n'est pas peuplant parce que vous n'avez pas spécifié dans votre script serveur.

Vous avez besoin de quelque chose comme mytable.id= gr.getValue('sys_id');