本文转自:http://angular-ui.github.io/ui-grid/

Getting Started

Steps for getting started (example on right):

    1. Add references to jQuery and AngularJS.
    2. Add references to ngGrid's javascript and css files.
    3. Where you declare your app module, add ngGrid: angular.module('myApp',['ngGrid']); If you use angular seed, 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:            
250
500
1000
                    
 
 

/ 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 here.

[转]ng-grid的更多相关文章

  1. ExtJS自制表格Grid分页条

    试过Grid自带的load和分页功能,没有成功,干脆就自己写了...... 主要是查询条件比较复杂...... 希望哪位大神能有更好的意见. Ext.define('MyApp.ux.Paginati ...

  2. Andrew Ng机器学习入门——线性回归

    本人从2017年起,开始涉猎机器学习.作为入门,首先学习的是斯坦福大学Andrew Ng(吴恩达)教授的Coursera课程 2 单变量线性回归 线性回归属于监督学习(Supervise Learni ...

  3. 【原】Coursera—Andrew Ng机器学习—编程作业 Programming Exercise 4—反向传播神经网络

    课程笔记 Coursera—Andrew Ng机器学习—课程笔记 Lecture 9_Neural Networks learning 作业说明 Exercise 4,Week 5,实现反向传播 ba ...

  4. [C2P2] Andrew Ng - Machine Learning

    ##Linear Regression with One Variable Linear regression predicts a real-valued output based on an in ...

  5. ExtJS 4.2 Grid组件的单元格合并

    ExtJS 4.2 Grid组件本身并没有提供单元格合并功能,需要自己实现这个功能. 目录 1. 原理 2. 多列合并 3. 代码与在线演示 1. 原理 1.1 HTML代码分析 首先创建一个Grid ...

  6. WPF中Grid实现网格,表格样式通用类

    /// <summary> /// 给Grid添加边框线 /// </summary> /// <param name="grid"></ ...

  7. 在 Windows Phone 中,为 Grid 添加 Tilt 效果

    在 Windows Phone 中,Tilt 效果是比较经典的效果,我们可以很简单的为按钮等控件添加这样的效果(使用 Windows Phone Toolkit 的Tilt 效果),但是,如果我们想要 ...

  8. wpf 列表、菜单 收起与展开,通过Grid DoubleAnimation或者Expander实现

    菜单收缩有很多种方法具体如何实现还是看个人想法: 第一种通过后台控制收起与展开: 效果图: 代码 : <Grid> <Grid.ColumnDefinitions> <C ...

  9. Sencha ExtJS 6 Widget Grid 入门

    最近由于业务需要,研究了一下Sencha ExtJS 6 ,虽然UI和性能上据相关资料说都有提升,但是用起来确实不太顺手,而且用Sencha cmd工具进行测试和发布,很多内部细节都是隐藏的,出了问题 ...

  10. WPF CheckBox样式 ScrollViewer样式 WrapPanel、StackPanel、Grid布局

    本节讲述布局,顺带加点样式给大家看看~单纯学布局,肯定是枯燥的~哈哈 那如上界面,该如何设计呢? 1.一些布局元素经常用到.Grid StackPanel Canvas WrapPanel等.如上这种 ...

随机推荐

  1. Code First :使用Entity. Framework编程(4) ----转发 收藏

    第4章 对关系使用默认规则与配置 在第3章,你已经掌握了默认规则与配置对属性以及其在数据库映射的字段的影响.在本章,我们把焦点放在类之间的关系上面.这包括类在内存如何关联,还有数据库中的外键维持等.你 ...

  2. Adaptive Backgrounds – jQuery 自适应背景插件

    Adaptive Backgrounds 是一款很特别的 jQuery 插件,可以从图像中提取主导颜色并将它应用到它的父元素.这个插件利用 Canvas 元素和 ImageData 对象.需要注意的是 ...

  3. CSS级联和继承

    2016-11-06 <CSS入门经典>第七章 1.在HTML中使用CSS样式表的三种方式: (1)内联的样式表. eg:<em style="background-whi ...

  4. 【iScroll源码学习02】分解iScroll三个核心事件点

    前言 最近两天看到很多的总结性发言,我想想今年好像我的变化挺大的,是不是该晚上来水一发呢?嗯,决定了,晚上来水一发! 上周六,我们简单模拟了下iScroll的实现,周日我们开始了学习iScroll的源 ...

  5. Windows服务器如何选 搭建WAMP环境

    Windows Server 2003 Windows Server 2008 如何选择服务器系统版本.原文地址:http://www.xwamp.com/learn/1. 系统版本: Windows ...

  6. select中无法使用click的处理

    今天工作用到了select,想要给option添加click点击事件,可是却没有任何效果,百度了才发现,原来竟然是不支持呀! 众所周知(其实我才知道哎),在IE里, select的option是不支持 ...

  7. Web前端面试笔试题总结

    最近一段时间要毕业了,忙着找工作,见过不少笔试面试题,自己总结了一些加上网上找的一些整合了一下.答案暂时都东拼西凑出来了,但是还是先不发出来,一方面是答案并不是唯一的并且自己的答案不能保证对,另一方面 ...

  8. SharePoint 2013 操作文档库ECB菜单

    在SharePoint的使用中,我们经常需要定制SharePoint的一系列菜单,这里就包括ECB菜单,下面,我们简单了解一下ECB菜单如何定制,以及原理. 1.正常情况文档库的ECB菜单如下图: 2 ...

  9. sqlmap笔记

    sqlmap -u "注入链接" --其他参数或命令 (-v 1表示回显出注入过程) [判断指定字段是否存在注入点]当链接包含两个参数时,可用-p开关选择要注入的参数,例检测id是 ...

  10. Android Studio 更换国内源下载依赖库

    我的博客:http://daycoding.com 小小程序猿 由于国内GFW的原因,经常导致android studio 莫名其妙的编译不了,多数原因是由于不能下载依赖库 Gradle支持三种不同的 ...