0

A duvida é a seguinte eu preciso criar uma linha em minha tabela sempre a data mudar como poderia fazer isso segue a tabela:

<table  class="table table-striped" height="100%">
    <thead>
        <tr>
            <th width="170px" class="fileName alignCenter"><label class="titLabel">Date Event</label></th>
            <th width="170px" class="fileName alignCenter"><label class="titLabel">Event Type</label></th>
            <th width="150px"  class="alignCenter"><label class="titLabel">&nbsp;RE1A</label></th>
            <th width="150px" class="alignCenter"><label class="titLabel">&nbsp;RE2A</label></th>
            <th width="150px" class="alignCenter"><label class="titLabel">&nbsp;RE3A</label></th>
            <th width="150px" class="alignCenter"><label class="titLabel">&nbsp;RE4A</label></th>
            <th width="150px" class="alignCenter"><label class="titLabel">&nbsp;RE5A</label></th>
            <th width="150px" class="alignCenter"><label class="titLabel">&nbsp;RE6A</label></th>
            <th width="150px" class="alignCenter"><label class="titLabel">&nbsp;RE7A</label></th>
            <th width="150px" class="alignCenter"><label class="titLabel">&nbsp;Total Event</label></th>
        </tr>
    </thead>
    <tbody>
        <tr id="no-results" ng-hide="{{noResults}}" ng-show="{{!noResults}}">
        </tr>
        <tr ng-repeat="output in result">
            <td width="170px" class="alignCenter"><label>&nbsp;{{output.referenceDate | date:'dd/MM/yyyy'}}</label></td>
            <td width="170px" class="alignCenter"><label>&nbsp;{{output.eventType}}</label></td>
            <td width="170px" class="alignCenter"><label>&nbsp;{{output.re1A}}</label></td>
            <td width="170px" class="alignCenter"><label>&nbsp;{{output.re2A}}</label></td>
            <td width="170px" class="alignCenter"><label>&nbsp;{{output.re3A}}</label></td>
            <td width="170px" class="alignCenter"><label>&nbsp;{{output.re4A}}</label></td>
            <td width="170px" class="alignCenter"><label>&nbsp;{{output.re5A}}</label></td>
            <td width="170px" class="alignCenter"><label>&nbsp;{{output.re6A}}</label></td>
            <td width="170px" class="alignCenter"><label>&nbsp;{{output.re7A}}</label></td>
            <td width="170px" class="alignCenter"><label>&nbsp;{{(output.re1A)+(output.re2A)+(output.re3A)+(output.re3A)+(output.re4A)+(output.re5A)+(output.re6A)+(output.re7A)}}</label></td>
        </tr>
        <tr  class="primary">
            <td width="170px" class="alignCenter" bgcolor="#044a75"><label class="titLabel">Total RE</label></td>
            <td width="170px" class="alignCenter" bgcolor="#044a75"><label class="titLabel">{{output.eventType}}</label></td>
            <td width="170px" class="alignCenter" bgcolor="#044a75"><label class="titLabel">{{totalizarRE1A()}}</label></td>
            <td width="170px" class="alignCenter" bgcolor="#044a75"><label class="titLabel">{{totalizarRE2A()}}</label></td>
            <td width="170px" class="alignCenter" bgcolor="#044a75"><label class="titLabel">{{totalizarRE3A()}}</label></td>
            <td width="170px" class="alignCenter" bgcolor="#044a75"><label class="titLabel">{{totalizarRE4A()}}</label></td>
            <td width="170px" class="alignCenter" bgcolor="#044a75"><label class="titLabel">{{totalizarRE5A()}}</label></td>
            <td width="170px" class="alignCenter" bgcolor="#044a75"><label class="titLabel">{{totalizarRE6A()}}</label></td>
            <td width="170px" class="alignCenter" bgcolor="#044a75"><label class="titLabel">{{totalizarRE7A()}}</label></td>
            <td width="170px" class="alignCenter" bgcolor="#044a75"><label class="titLabel">{{totalEvent()}}</label></td>
        </tr>   

A linha que preciso criar de forma dinâmica seria essa segunda linha.

1
  • Sem o CSS que você usou o código fica difícil de analisar. 18/02/2019 às 19:51

1 Resposta 1

0

Vou resumir um pouco o código, mas podes usar assim:

<td ... ng-repeat="item in list"> {{ generateTotal(item) }} </td>

E no controlador tens de criar:

var list = ['RE1A', ... , 'RE10A'];

var generateTotal = function(value){
  switch(value){
    case 'RE1A': ...
    ...
  }
}

Poderá haver outras formas, mas acho que assim resolves o teu problema. Depois tens de ver o teu código e gerar o array list dinamicamente.

1
  • opa entao cara não entendi muito bem por que eu preciso montar essa linha comparando com a data que esta na tabela quando a data mudar eu preciso criar a linha
    – Wesley S
    19/02/2019 às 12:38

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .