简体   繁体   中英

Data placed outside of Angular ui-grid

We have plenty of server-side data grid controls, would like to replace them w/ generic clientside Angular. But data is always placed outside of the grid. To find out the cause, I followed the official demo/tutorial , combine .js and .css into local.html, still the same result. enter image description here

Visual Studio 2015 w/ Update, NuGet installed ui-grid(v3.2.9 - 2016-09-21). Must be something missing or the demo has problem.

Here is local.html:

<!doctype html>
<html ng-app="app">
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-touch.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js"></script>
    <script src="http://ui-grid.info/docs/grunt-scripts/csv.js"></script>
    <script src="http://ui-grid.info/docs/grunt-scripts/pdfmake.js"></script>
    <script src="http://ui-grid.info/docs/grunt-scripts/vfs_fonts.js"></script>
    <script src="/Scripts/ui-grid.js"></script>
    <script src="/Content/ui-grid.css"></script>

    <style>
        .grid {  width: 500px;  height: 250px;}
    </style>

    <script>
        var app = angular.module('app', ['ngTouch', 'ui.grid']);

        app.controller('MainCtrl', ['$scope', function ($scope) {

            $scope.myData = [
              {
                  "firstName": "Cox",
                  "lastName": "Carney",
                  "company": "Enormo",
                  "employed": true
              },
              {
                  "firstName": "Lorraine",
                  "lastName": "Wise",
                  "company": "Comveyer",
                  "employed": false
              },
              {
                  "firstName": "Nancy",
                  "lastName": "Waters",
                  "company": "Fuelton",
                  "employed": false
              }
            ];
        }]);
    </script>
</head>
<body>
    <div ng-controller="MainCtrl">
        <div id="grid1" ui-grid="{ data: myData }" class="grid"></div>
    </div>
</body>
</html>

Stupid me, I was loading .css using tag. So this line

<script src="/Content/ui-grid.css"></script>

should be this instead:

<link rel="stylesheet" type="text/css" href="/Content/ui-grid.css">

It's been working as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM