AngularJs Table with showing top 5 and bottom 5 rows?

Samir Shah

I am new to Angularjs and i want to show top 5 and bottom 5 rows in between click all functionality which shows all the records. I tried different things but not able to get success.

            <div class="col-md-12">
          <div class="dataTables_wrapper" id="comparison-table">
            <table class="datatable">
              <thead>
                <tr>
                  <th width="5%">A</th>
                  <th width="10%">B</th>
                  <th width="25%" class="text-left">C</th>
                  <th width="15%">D</th>
                  <th width="15%">E</th>
                  <th width="15%">F</th>
                  <th width="15%">G</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td>1</td>
                  <td>##</td>
                  <td class="text-left">AA</td>
                  <td>12</td>
                  <td>12</td>
                  <td>2</td>
                  <td>4</td>
                </tr>
                <tr>
                  <td>2</td>
                  <td>##</td>
                  <td class="text-left">BB</td>
                  <td>12</td>
                  <td>11.7</td>
                  <td>1</td>
                  <td>2</td>
                </tr>
                <tr>
                  <td>3</td>
                  <td>##</td>
                  <td class="text-left">CC</td>
                  <td>12</td>
                  <td>11.7</td>
                  <td>1</td>
                  <td>2</td>
                </tr>
                <tr>
                  <td>4</td>
                  <td>##</td>
                  <td class="text-left">DD</td>
                  <td>11.7</td>
                  <td>10.7</td>
                  <td>9</td>
                  <td>3</td>
                </tr>
                <tr>
                  <td>5</td>
                  <td>##</td>
                  <td class="text-left">EE</td>
                  <td>12</td>
                  <td>10.4</td>
                  <td>3</td>
                  <td>9</td>
                </tr>
                <tr>
                  <td class="text-center br" colspan="7"> <a href="#">Click to view all</a></td>
                </tr>
                <tr>
                  <td>32</td>
                  <td>##</td>
                  <td class="text-left">FF</td>
                  <td>12</td>
                  <td>12</td>
                  <td>2</td>
                  <td>4</td>
                </tr>
                <tr>
                  <td>33</td>
                  <td>##</td>
                  <td class="text-left">GG</td>
                  <td>12</td>
                  <td>11.7</td>
                  <td>1</td>
                  <td>2</td>
                </tr>
                <tr>
                  <td>34</td>
                  <td>##</td>
                  <td class="text-left">HH</td>
                  <td>12</td>
                  <td>11.7</td>
                  <td>1</td>
                  <td>2</td>
                </tr>
                <tr>
                  <td>35</td>
                  <td>##</td>
                  <td class="text-left">II</td>
                  <td>11.7</td>
                  <td>10.7</td>
                  <td>9</td>
                  <td>3</td>
                </tr>
                <tr>
                  <td>36</td>
                  <td>##</td>
                  <td class="text-left">JJ</td>
                  <td>12</td>
                  <td>10.4</td>
                  <td>3</td>
                  <td>9</td>
                </tr>
              </tbody>
            </table>
          </div>

please find the fiddle just for demo purpose - http://jsfiddle.net/samirshah1187/Br28J/

scarlz

Assuming I have understood your question correctly, you want the first and last five rows to always be visible, with the option to toggle the rows inbetween? If so, try this:

Controller:

function MyCtrl($scope) {
    // Create Test Array
    $scope.myArray  = Array.apply(null, {length: 20}).map(Number.call, Number)
    $scope.hideRows = true

    $scope.toggleHiddenRows = function() {
      $scope.hideRows = !$scope.hideRows
    }
}

View:

<body ng-controller="MyCtrl">
  <table>
    <tr ng-repeat="value in myArray" ng-hide="hideRows && $index > 4 && $index < (myArray.length - 5)">
      <td>Row: {{value}}</td>
    </tr>
    </table>
  <button ng-click="toggleHiddenRows()">Toggle Hidden Rows</button>
</body>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

in R output shows top and bottom 5 rows of data

From Dev

Creating 5 reports from top 5 rows of filtered table

From Dev

Top 5 rows by month

From Dev

Get top 5 rows per row in related table

From Dev

Select TOP row in SQL and get 5 rows of end table

From Dev

Selecting the top 5 rows from a joined table, into the result of a larger query?

From Dev

Selecting the top 5 rows from a joined table, into the result of a larger query?

From Dev

html5: three-rows flexbox with fixed top/bottom and scrollable middle

From Dev

iOS static table view showing some dummy rows at the bottom

From Dev

How to select top 5 after 20 rows

From Dev

How to select top 5 after 20 rows

From Dev

Sticking HTML 5 table footer at bottom of the page

From Dev

Xcode 5 not displaying Top/Bottom Layout Guides for TableViewControllers

From Dev

In Xcode 5 in a GLKViewController in IB what are the Top/Bottom Layout guides for?

From Dev

Xcode 5 not displaying Top/Bottom Layout Guides for TableViewControllers

From Dev

how to cut black area on top and bottom of the HTML5 video?

From Dev

how to select top 5 products from table

From Dev

Unlimited rows with bottom and top shadows

From Dev

angularjs infinite scroll bottom top

From Dev

Sorting array of objects to list top 5 and bottom 5 elements based on object value

From Dev

Force table to display 5 rows with or without data

From Dev

A Top Bar with 2 navigation rows - Zurb Foundation 5

From Dev

LINQ grouping and ordering of top 5 rows into ViewModel List

From Dev

Excel VBA: Filter and copy from top 5 rows/cells

From Dev

How to select top (5) rows with specified Id and latest date?

From Dev

Count Top 5 Elements spread over rows and columns

From Dev

Python - Finding the top 5 rows containing a word in a dataframe

From Dev

MySQL: Select top 5 rows based on ID and find Subtotal

From Dev

Adding pager to top and bottom of the table

Related Related

  1. 1

    in R output shows top and bottom 5 rows of data

  2. 2

    Creating 5 reports from top 5 rows of filtered table

  3. 3

    Top 5 rows by month

  4. 4

    Get top 5 rows per row in related table

  5. 5

    Select TOP row in SQL and get 5 rows of end table

  6. 6

    Selecting the top 5 rows from a joined table, into the result of a larger query?

  7. 7

    Selecting the top 5 rows from a joined table, into the result of a larger query?

  8. 8

    html5: three-rows flexbox with fixed top/bottom and scrollable middle

  9. 9

    iOS static table view showing some dummy rows at the bottom

  10. 10

    How to select top 5 after 20 rows

  11. 11

    How to select top 5 after 20 rows

  12. 12

    Sticking HTML 5 table footer at bottom of the page

  13. 13

    Xcode 5 not displaying Top/Bottom Layout Guides for TableViewControllers

  14. 14

    In Xcode 5 in a GLKViewController in IB what are the Top/Bottom Layout guides for?

  15. 15

    Xcode 5 not displaying Top/Bottom Layout Guides for TableViewControllers

  16. 16

    how to cut black area on top and bottom of the HTML5 video?

  17. 17

    how to select top 5 products from table

  18. 18

    Unlimited rows with bottom and top shadows

  19. 19

    angularjs infinite scroll bottom top

  20. 20

    Sorting array of objects to list top 5 and bottom 5 elements based on object value

  21. 21

    Force table to display 5 rows with or without data

  22. 22

    A Top Bar with 2 navigation rows - Zurb Foundation 5

  23. 23

    LINQ grouping and ordering of top 5 rows into ViewModel List

  24. 24

    Excel VBA: Filter and copy from top 5 rows/cells

  25. 25

    How to select top (5) rows with specified Id and latest date?

  26. 26

    Count Top 5 Elements spread over rows and columns

  27. 27

    Python - Finding the top 5 rows containing a word in a dataframe

  28. 28

    MySQL: Select top 5 rows based on ID and find Subtotal

  29. 29

    Adding pager to top and bottom of the table

HotTag

Archive