ServiceNow服务门户AngularJS Accordian小工具不起作用

时间:2017-10-13 20:09:38

标签: angularjs servicenow

我是serviceNow的新手,并尝试创建一个Accordian Widget,以便在按ProjectName分组的表中显示信息。

当我在窗口小部件编辑器中运行此代码时,会出现手风琴,但{{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”>
		<a role=”button” data-toggle=”collapse” href=”#collapse_{{mytable.id}}” aria-expanded=”true” aria-controls=”collapse_{{::mytable.id}}”>
			<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);
    }
})();
      

1 个答案:

答案 0 :(得分:0)

{{mytable.id}}未填充,因为您未在服务器脚本中指定它。

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

之类的内容