1

I'm intending to create a salesforce app using angularjs and ionic framework. I've been trying in vain to visualize an arbitrary array in a modal window and failing. Have asked elsewhere but no luck. My plunkr is: http://plnkr.co/edit/wZVItjUwYPExllECYzM7

As you can see, clicking "display" brings up the window but the array is not displayed.

angular.module('starter.controllers', ['ngGrid'])

.controller('AppCtrl', function($scope) {})

.controller('DisplayCtrl', function($scope, ModalFactory) {

$scope.array = []; //initialize to null

$scope.run = function() { 

$scope.array = $scope.array.concat( [{ //arbitrary array of UNKNOWN fields
  "a": 0,
  "b": 1
}, {
  "a": 1,
  "b": 8
}, {
  "a": 2,
  "b": 5
}, {
  "a": 3,
  "b": 7
}, {
  "a": 4,
  "b": 0
}, {
  "a": 5,
  "b": 3
}, {
  "a": 6,
  "b": 6
}, {
  "a": 7,
  "b": 4
}, {
  "a": 8,
  "b": 2
}, {
  "a": 9,
  "b": 9
}]);

    //$scope.array = array;
    ModalFactory.init($scope).then(function(modal) {
                            modal.show();
                });
}

});

HTML is

<div class="modal">
<ion-header-bar>
  <h1 class="title">output array</h1>
<div class="buttons">
    <button class="button button-icon ion-ios7-close-empty" ng-click="closeModal()"></button>
</div>
</ion-header-bar>
<ion-content>
    <div ng-grid="{data: 'array'}" class="grid"></div>
</ion-content>
</div>

1 Answer 1

0

If you use "Inspect Element" when the dialog has been displayed in Plunker, the body of the table is in this div:

<div class="ngViewport" ... style="width: 638px; height: 16px;">

and if you change the 16px to say 350px you see all the table rows.

So the question is how to get ng-grid to compute the correct height; unfortunately I don't know the answer to that.

PS

Possibly this problem https://github.com/angular-ui/ng-grid/issues/189 you are seeing. The basic fix is to add a hard-coded height to your style sheet and that works in your Plunker:

.ngViewport {
  height: 200px;
}

If the content has a fixed number of rows you can tweak that to match. If the number of rows varies you can pick a size and a scroll bar appears if the content is bigger.

1
  • Thank you, lets wait if we can get some more answers. If not I'll mark yours as accepted. Commented Dec 4, 2014 at 21:50

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.