博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[转]ng-grid
阅读量:4944 次
发布时间:2019-06-11

本文共 2383 字,大约阅读时间需要 7 分钟。

本文转自:

Getting Started

Steps for getting started (example on right):

    1. Add references to and .
    2. Add references to 's javascript and css files.
    3. Where you declare your app module, add ngGrid: angular.module('myApp',['ngGrid']); If you use , it is in your app.js file.
    4. In your html file within the controller where you plan to use ng-grid, add: <div class="gridStyle" ng-grid="gridOptions"></div> gridOptions is the variable we are going to bind to where we will initialize our grid options.
    5. We are going to define a basic style for our grid in style.css:
      .gridStyle {
      border: 1px solid rgb(212,212,212); width: 400px; height: 300px }
    6. In your javascript file within the controller where you plan to use ng-grid, lets add data that our grid will use:
$scope.myData = [{ name: "Moroni", age: 50}, { name: "Tiancum", age: 43}, { name: "Jacob", age: 27}, { name: "Nephi", age: 29}, { name: "Enos", age: 34}];
  1. Now initialize your grid options under the same controller as data: $scope.gridOptions = { data: 'myData' };
  2. Below is the outcome of the grid using the example on the right:
Drag a column header here and drop it to group by that column.
  •         
 
name
 
 
 
 
 
 
age
 
 
 
 
 
 
    
Choose Columns:        
  •                  name 0                     
  • age 0                     
 
Moroni
 
50
 
Tiancum
 
43
 
Jacob
 
27
 
Nephi
 
29
 
Enos
 
34
Total Items: 5(Showing Items: 5)        
Selected Items: 0        
Page Size:            2505001000                     
 
            
 
                         
/ 1            
 
            
 
        

HTML:

  1. <html ng-app="myApp">
  2. <head lang="en">
  3. <meta charset="utf-8">
  4. <title>Getting Started With ngGrid Example</title>
  5. <link rel="stylesheet" type="text/css" href="ng-grid.css" />
  6. <link rel="stylesheet" type="text/css" href="style.css" />
  7. <script type="text/javascript" src="jquery-1.8.2.js"></script>
  8. <script type="text/javascript" src="angular.js"></script>
  9. <script type="text/javascript" src="ng-grid-1.3.2.js"></script>
  10. <script type="text/javascript" src="main.js"></script>
  11. </head>
  12. <body ng-controller="MyCtrl">
  13. <div class="gridStyle" ng-grid="gridOptions">
  14. </div>
  15. </body>
  16. </html>

CSS:

  1. /*style.css*/
  2. .gridStyle {
  3. border: 1px solid rgb(212,212,212);
  4. width: 400px;
  5. height: 300px
  6. }

Javascript:

  1. // main.js
  2. var app = angular.module('myApp', ['ngGrid']);
  3. app.controller('MyCtrl', function($scope) {
  4. $scope.myData = [{
    name: "Moroni", age: 50},
  5. {
    name: "Tiancum", age: 43},
  6. {
    name: "Jacob", age: 27},
  7. {
    name: "Nephi", age: 29},
  8. {
    name: "Enos", age: 34}];
  9. $scope.gridOptions = {
    data: 'myData' };
  10. });

View the plunker .

 

转载于:https://www.cnblogs.com/freeliver54/p/5234990.html

你可能感兴趣的文章
C语言、C语言的起源以及类似C语言的编程语言的历史简直不要太漫长,我简单总结列表如下:...
查看>>
sp1.3-1.4 Neural Networks and Deep Learning
查看>>
JavaScript易错知识点整理
查看>>
Biological Clocks
查看>>
2018-10-11
查看>>
国内NLP的那些人那些会
查看>>
SQL 将一个表中的所有记录插入到一个临时表中
查看>>
nmea协议
查看>>
js 中对象的特性
查看>>
hdoj3714【三分】
查看>>
嵌入式开发入门(4)—驱动入门之时序图分析【20121211修改,未完】
查看>>
Python 使用字符串
查看>>
Quartz Core之CALayer
查看>>
java:一个项目的开发过程(转)
查看>>
express框架学习笔记
查看>>
操作系统下载路径
查看>>
网站开发 关于图片压缩 以及图片使用
查看>>
hive的count(distinct id)测试--慎用
查看>>
第九周周总结
查看>>
Logistic Regression
查看>>