使用angularjs ng-repeat -start和ng-repeat-end扩展和折叠表行

时间:2017-05-18 07:14:44

标签: html angularjs

我有一个问题,任何人都可以帮助我... 我在该表中有一个表,我有四个用户。我有两个图标(一个用于扩展,另一个用于折叠表时行数据(全部))当我点击展开图标时表格中的数据展开和折叠。所以,直到这对我好。现在我要通过单击箭头(实际存在于tr中)扩展特定行的表,它扩展了特定行并折叠了该特定行。然后这次如果点击展开和折叠图标(展开全部并折叠全部)。然后扩展和崩溃不起作用。 这里使用的是ng-repeat-start和ng-repeat-end。

<div class="comprehensiveINDiv" ng-show="visibleCarConferenceList">
  <div class="top-bg-expand" >
    <div class="col-md-5 color-blue">
      <h1 class="main-heading1 ">Care Conference
        <span class="expand-btns">
          <a><i class="fa fa-compress color-blue" aria-hidden="true" ng-click="expanded = true"></i></a>
          &nbsp; | &nbsp;
          <a><i class="fa fa-expand" aria-hidden="true" ng-click="loadAllcareplans(); expanded = !expanded"></i></a>
        </span>
      </h1>
    </div>
    <div class="col-md-3 select-pan1 select-inner-pan1 careconfhed">
      <label>Status: </label>
      <select ng-model="filterOpt.opt"
        ng-options="item.name for item in filterOpts.options"
        ng-change="getCareConferenceList();resetPage();"> 
      </select>
    </div>

    <div class="col-md-4 ">
      <sm-range-picker-input class="margn0" fname="Range" label="Range" 
        form="test" ng-model="vm.rangeSelected" flex="100"
        format="DD-MMM-YYYY" divider="To" week-start-day="Monday"
        on-range-select="rangeSelected(range)"
        ng-change="getCareConferenceList();">
      </sm-range-picker-input>
        </div>
      </div>
      <div ng-show="noConfData" class="margnL15">NO RECORDS FOUND</div>
      <div>
        <button type="button" class="btn btn-info btn-sm margnL15" 
          id="addnew_btn" ng-click="addNewconference();">ADD NEW</button>
      </div>
      <div ng-show="confGrid">
        <div class="col-md-12">
          <div class="table-responsive">
            <table class="table table-data3 tablestyle" id="tbl1">
              <thead>
                <tr>
                  <th></th>
                  <th> Date / Time </th>
                  <th>Reason</th>
                  <th>Status </th>
                  <th>Action</th>
                  <!--<th>time</th>-->
                </tr>
              </thead>
              <tbody>
                <tr ng-show="noConfData"><td colspan="4" >NO RECORDS FOUND</td></tr>
                <tr ng-repeat-start="careconf in residentCareConferenceList" class="md-table-content-row class_{{careconf.CareConferenceID}}">
                  <td><a  ng-click="expanded = !expanded"><i class="fa fa-angle-right" aria-hidden="true"></i></a></td>
                  <td ng-class="customClass[h.field]" class="md-table-content">{{careconf.CareConferenceDate | date:'dd/MM/yyyy hh:mm a'}}</td>
                  <td ng-class="customClass[h.field]" class="md-table-content">{{careconf.ReasonDescription}}</td>
                  <td ng-class="customClass[h.field]" class="md-table-content">{{careconf.careconferencestatus.CareConferenceStatusDescription}}</td>
                  <td><span class="fa fa-pencil" ng-click="EditCareConference(careconf.CareConferenceID);$event.stopPropagation();"></span></td>
                  <!--<td ng-class="customClass[h.field]" class="md-table-content">{{careconf.TotalTime}}</td>-->
                </tr>

                <tr ng-repeat-end ng-class="{'hide' : expanded}">
                  <td colspan="5" style="width: 100%; border:none !important; padding-left:20px;">
                    <div class="col-md-12  scrolldata">
                      <div class="col-md-12 ">
                        <div class="col-md-12 residance-data-text">
                          <p>Facility :{{careconf.facilitybase.FacilityName }}</p>
                          <p> Resident : {{currentResident.personbase.FullName}}</p>
                          <p> Admitted :{{currentResidentDetails.AdmitReAdmiDischDate | date:'dd/MM/yyyy hh:mm a'}}</p>
                          <p> Physician : {{residentprovider}}</p>
                        </div>
                      </div>
                      <div class="col-md-12" id="table">
                        <div class="col-md-12">
                          <!-- Table one -->
                          <p> Interdisciplinary team members involved in this Resident's Care Planning since last Care Conference ({{careconf.LastCareConferenceDate | date:'dd/MM/yyyy hh:mm a'}}) :</p>
                          <div class="tablestyledit">
                            <table class="table">
                              <tr>
                                <th width="50%" class="bdr-table">Name </th>
                                <th width="50%" class="bdr-table">Credentials </th>
                              </tr>
                              <tr ng-repeat="teamMember in careconf.teamMembers">
                                <td class="bdr-table">{{teamMember.ParticipantName}}</td>
                                <td class="bdr-table">{{teamMember.ParticipantRole}}</td>
                              </tr>
                            </table>
                          </div>

                          <div class="col-md-12" style="padding-top:0px;">
                            <div class="row">
                              <div class="md-form">
                                <p style="margin:0px;">Care Conference Summary</p>
                                <div class="empty-text">{{careconf.CareConferenceSummary}}</div>
                              </div>
                            </div>
                          </div>
                          <!--- /Table one -->

                          <!-- Table two -->
                          <div class="col-md-12" style="padding:0px;">
                            <p style="margin:0px; padding-top:10px;">Care Conference Participants :</p>
                            <div class="tablestyledit">
                              <table class="table ">
                                <tr>
                                  <th width="50%" class="bdr-table">IDT Participant Name</th>
                                  <th width="25%" class="bdr-table">Credentials</th>
                                  <th width="25%" class="bdr-table">In Person</th>
                                </tr>
                                <tr ng-repeat="participant in careconf.participants">
                                  <td class="bdr-table">{{participant.ParticipantName}}</td>
                                  <td class="bdr-table">{{participant.ParticipantRole}}</td>
                                  <td class="bdr-table">
                                    <fieldset class="form-group">
                                      <input type="checkbox" data-ng-model="participant.IsInPerson" disabled>
                                    </fieldset>
                                  </td>
                                </tr>
                              </table>
                            </div>
                          </div>
                          <!--/ Table two -->

                          <!-- Table three -->
                          <div class="col-md-12" style="padding:0px;">
                            <p style="margin:0px; padding-top:10px;">Family/Resident Attendance : </p>
                            <div class="tablestyledit">
                              <table class="table table-data-sub ">
                                <tr>
                                  <th class="bdr-table">Name of person Invited</th>
                                  <th class="bdr-table">Relationship</th>
                                  <th class="bdr-table">Attended</th>
                                  <th class="bdr-table">In Person</th>
                                </tr>
                                <tr ng-repeat="familyMember in careconf.familyMembers">
                                  <td class="bdr-table">{{familyMember.ParticipantName}}</td>
                                  <td class="bdr-table">{{familyMember.Relationship}}</td>
                                  <td class="bdr-table">
                                    <fieldset class="form-group">
                                      <input type="checkbox" data-ng-model="familyMember.HasAttended" disabled>
                                    </fieldset>
                                  </td>
                                  <td class="bdr-table">
                                    <fieldset class="form-group">
                                      <input type="checkbox" data-ng-model="familyMember.IsInPerson" disabled>
                                    </fieldset>
                                  </td>
                                </tr>
                              </table>
                            </div>
                          </div>
                          <div class="col-md-12" style="margin-left:-15px;margin-bottom:8px;">
                            <p> Care Conference Date : {{careconf.CareConferenceDate | date:'dd/MM/yyyy hh:mm a'}}</p>
                            <p>Signed by:</p>
                          </div>
                        </div>
                      </div>
                    </div>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
          <div>
            <div flex layout="column" class="pagi-nation">
              <div ng-show="confTotal > 1" flex layout="column">
                <section layout="row" layout-padding="">
                  <div class="col-md-5 col-xs-12">Showing Page <strong>{{confPage}}</strong></div>
                  <div class="col-md-7 col-xs-12">
                    <cl-paging id="confPage" flex cl-pages="confTotal" , cl-steps="3" , cl-page-changed="loadConfPages.onPageChanged()" , cl-align="center center"
                    , cl-current-page="Paging.currentPage"></cl-paging>
                </section>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div ng-show="visibleCarConferenceAdd">
      <div ng-include="'views/doctor/addCareConference.html'"></div>
    </div>
  </div>

和我的控制器代码

  $scope.loadAllcareplans = function () {
    $scope.expanded = true;
  }

最后我很抱歉我的愚蠢英语。并检查我的功能性(扩展,$ scope.loadAllcareplans()和图标在careconference foe扩展和折叠所有表格数据)

2 个答案:

答案 0 :(得分:1)

检查这个小提琴

内容不是您提供的内容。

但逻辑将是这个

https://jsfiddle.net/athulnair/wkz5oq9z/

$scope.collapseAll = function() {
    $scope.data.forEach(function(item) {
                item.isCollapsed = false;
    })
}

答案 1 :(得分:0)

您可以使用javascript并动态添加/删除类,而不是在标记中使用上述 ng-click 函数。我使用了ui-bootstrap和glyphicon。请遵循以下代码。

HTML:

<a data-toggle="collapse" data-target="#test"><i class="test_icon glyphicon  glyphicon-collapse-down"></i><h4 class="header"> Test Class </h4></a>

的JavaScript

 $('#test').on('hidden.bs.collapse', function () {

           $(".test_icon").removeClass("glyphicon-collapse-down").addClass("glyphicon-collapse-up");
        });
         $('#test').on('shown.bs.collapse', function () {

           $(".test_icon").removeClass("glyphicon-collapse-up").addClass("glyphicon-collapse-down");
        });