0

In following demo I am showing more than one value in single cell of table. If any particular row's cell has one value then nothing to do. But if it has more than one value, then we can hide and show the values. Hiding and showing are happening in same cell.

I want to do this in separate div. So that If number of value are more the It won't effect the table.like It open some div and show all values from cell inside that dev..

Please see the demo, Last row has more than one value for ID column. I want to show this expansion in separate DIV

Please see DEMO

View

 <tbody>
      <tr ng-repeat="todolist in todolists">
        <td>
             <span ng-repeat="list in todolist.id| limitTo: showMore ? todolist.id.length:1">
     <a target="_blank" href="{{ 'http://'+common_url}}{{list}}"> {{list}}</a>
 </span> 
     <a ng-show="todolist.id.length>1 && showMore==false" ng-click="showMore = true">....show {{todolist.id.length-1}} more</a>
     <a ng-show="showMore==true" ng-click="showMore = false">....show less</a>
        </td>
        <td>{{todolist.bill_number}}</td>
        <td>{{todolist.location}}</td>
        <td><a target="_blank" href="{{ 'http://' + todolist.url}}">Download Invoice : <i title="Download Invoice" style="padding-left:5px;cursor:pointer;color:black;" class="fa fa-download"></i></a> </td>

      </tr>
    </tbody>
  </table>

Controller

.controller('ctrl', function($scope) {
        $scope.showMore=false;
        $scope.common_url="localhost:8000";
        $scope.todolists = [{
          "id": "id_584",
          "customer_id": 2,
          "url": "url",
          "bill_number": "123",
          "location": "from_location"
        }, {
          "id": "id_122",
          "customer_id": 3,
          "url": "url",
          "bill_number": "123",
          "location": "from_location"
        }, {
          "id": "id_128",
          "customer_id": 4,
          "url": "url",
          "bill_number": "123",
          "location": "from_location"
        }, {
          "id": "id_805",
          "customer_id": 5,
          "url": "url",
          "bill_number": "123",
          "location": "from_location"
        }, {
          "id": "id_588",
          "customer_id": 6,
          "url": "url",
          "bill_number": "123",
          "location": "from_location"
        }, {
          "id":"id_115,id_114,id_116,id_130,id_118,id_119",
          "customer_id": 7,
          "url": "url",
          "bill_number": "123",
          "location": "from_location"
        }]
                $scope.todolists.forEach(function(item){                    
          var multiple_orders = item.id.split(',');
          item.id=multiple_orders;
        });
      });
4
  • You can set fixed width to the first column, so showing and hiding will affect only the height of the row but not the width tr td:first-child {width: 40%;} Commented Jan 24, 2016 at 18:40
  • What are expected results and how do they differ from demo? Commented Jan 24, 2016 at 18:42
  • @charlietfl like It open some div and show all value from cell inside that dev.. Commented Jan 24, 2016 at 18:43
  • just pass the whole todolist object to a function in ng-click. In scope make it selectedItem or whatever you want to call it. Then template that div for same variable Commented Jan 24, 2016 at 18:46

2 Answers 2

1
<td style="word-wrap:break-word">
             <span ng-repeat="list in todolist.id| limitTo: showMore ? todolist.id.length:1">
     <a target="_blank" href="{{ 'http://'+common_url}}{{list}}"> <div>
       {{list}}
     </div></a>
 </span> 
     <a ng-show="todolist.id.length>1 && showMore==false" ng-click="showMore = true">....show {{todolist.id.length-1}} more</a>
     <a ng-show="showMore==true" ng-click="showMore = false">....show less</a>
        </td>

Try this

Sign up to request clarification or add additional context in comments.

Comments

0

Replace with your 'Show More" ng-click with this:

ng-click=" assignToDiv(todolist) "

and the function will be:

$scope.assignToDiv = function(arr){
    $scope.showInDiv = arr;
};

And then bind your div to the showInDiv (then show the div as desired):

<div>
      <a ng-repeat=" id in showInDiv.id " > {{ id }}</a> 
</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.