分享好友 前端技术首页 频道列表

ag-grid 在 angular 1.5 中使用

angular  2023-02-08 19:110

1、首先引入模块:

ag-grid 在 angular 1.5 中使用

 

2、然后引入样式:

ag-grid 在 angular 1.5 中使用

 

3、接着配置相关数据:

  //行内数据
    var rowData = [
        {name: "Toyota", model: "Celica", price: 35000,operation: 'a', folder: true, children: [{name:'3x', model:'sss', price:37000}]},
        {name: "Ford", model: "Mondeo", price: 32000,folder: true, open: true, children: [{name:'test', model:'test', price:100}]},
        {name: "Porsche", model: "Boxter", price: 72000}
    ];
    //列属性设置
    var columnDefs = [
        {
            headerName: 'Name',
            field: 'name',
            width: 400,
            enableRowGroup: true,
            checkboxSelection: function (params) {
                // we put checkbox on the name if we are not doing grouping
                return params.columnApi.getRowGroupColumns().length === 0;
            },
            headerCheckboxSelection: function (params) {
                // we put checkbox on the name if we are not doing grouping
                return params.columnApi.getRowGroupColumns().length === 0;
            },
            headerCheckboxSelectionFilteredOnly: true,
            cellRenderer: 'group',
            cellRendererParams: {
                innerRenderer: function (params) { return params.data.name; },
                suppressCount: true
            }
        },
        {headerName: "Model", field: "model"},
        {headerName: "Price", field: "price"},
        {headerName: "Operation", field: "operation", cellRenderer: function(params) { return '<button ng-click="btnClick(1);">click1</button> <button onclick="btnClick(2);">click2</button>'}}
    ];
    //表格设置
    $scope.gridOptions = {
        columnDefs: columnDefs,
        rowData: rowData,
        animateRows: true,
        enableColResize: true,
        rowHeight: 30,
        rowSelection: 'multiple',
        enableSorting: true,
        suppressDragLeaveHidesColumns: true,
        //行内点击触发事件
        onRowClicked: function(event) {
            //event.data 选中的行内数据,event.event 为鼠标事件,等其他。可以log自己看一下
            console.log('a row was clicked', event);
        },
        //列宽度改变触发
        onColumnResized: function(event) { console.log('a column was resized'); },
        //表格加载完成触发
        onGridReady: function(event) { console.log('the grid is now ready'); },
        //单元格点击触发
        onCellClicked: function(event) { console.log('a cell was cilcked'); },
        //单元格双击触发
        onCellDoubleClicked: function(event) { console.log('a cell was dbcilcked'); },

        //子节点显示
        getNodeChildDetails: function(file) {
            if (file.folder) {
                return {
                    group: true,
                    children: file.children,
                    expanded: file.open
                };
            } else {
                return null;
            }
        }
    };

 

4、最后在页面中调用配置:(这里我用的是pug文件,同理html)

ag-grid 在 angular 1.5 中使用

 

最后效果:

ag-grid 在 angular 1.5 中使用

 

查看更多关于【angular】的文章

展开全文
相关推荐
反对 0
举报 0
评论 0
图文资讯
热门推荐
优选好物
更多热点专题
更多推荐文章
Angular.js的作用域和数据绑定
初识Angular.js通过初识Angular.js可以做一个简单的入门,下面开始做深入的了解吧。作用域作用域($scope)和应用的数据模型相关联的,同时作用域也是表达式执行的上下文。$scope对象是定义应用业务逻辑、控制器方法和视图属性的地方。 作用域是视图和控制器

0评论2023-03-16944

angularJSapi学习-angular.copy使用
angular.copy使用效果:初始状态:输入信息后未保存状态:点击save后状态:当输入框内容和master内容不一致时:点击reset使得user的信息被重置为master中信息: 具体代码: 1 !DOCTYPE HTML 2 html ng-app="app" 3 headscript src="./angular.min.js"/script

0评论2023-03-16345

Angular.js之内置过滤器学习笔记 javascript过滤器
!DOCTYPE htmlhtml lang="en"headmeta charset="UTF-8"titleangularFilter/titlescript src="http://cdn.bootcss.com/angular.js/1.4.6/angular.js"/script/head  body ng-app="angularJS" ng-controller="ctrl"    div{{

0评论2023-03-08452

Angular 隨記
Windows下更新Node 和NPM方法管理員模式打開powershell執行以下命令:Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Forcenpm install -g npm-windows-upgradenpm-windows-upgrade

0评论2023-03-08858

双向数据绑定(angular,vue) 双向数据绑定指令
最近github上插件项目更新了关于双向数据绑定的实现方式,关于angular和vue.angular众所周知是使用的脏检查($dirty)。一开始大家会认为angular开启了类似setInterval去不停的循环检查,性能极差,但其实并不是,$dirty是在一定条件下才会去执行,比如输入框

0评论2023-03-08953

angular.js使用ui-router注入报错,这里是版本问题导致的
 报错如下:common.ts:604Uncaught SyntaxError: Unexpected token ) stateEvents.ts:211Uncaught SyntaxError: Unexpected token ) jquery.js:3827 Uncaught Error: [$injector:modulerr] Failed to instantiate module salesApp due to: Error: [$injector

0评论2023-03-08406

angular5给懒加载模块添加loading angular2懒加载
在根组件的构造函数中直接执行:this.router.events.subscribe(event={if(event instanceof RouteConfigLoadEnd) {this.toast.hide();}if(event instanceof RouteConfigLoadStart) {this.toast.loading();} }); 

0评论2023-03-08610

mean(bootstrap,angular,express,node,mongodb)通用后台框架
学习node,我这个毫无美感的程序员在bootstrap与node的感染下,向着“全栈工程师”迈进,呵呵!最终选择如题的技术方案,这些东东都算比较新的,网上的资料比较少,参考了不少github程序及自己的努力,终于有一些感觉了,于是开贴记录一些感悟,供自己与同道

0评论2023-03-08393

Angular 核心概念
module(模块)作用通过模块对页面进行业务上的划分,根据不同的功能划分不同的模块。将重复使用的指令或者过滤器之类的代码做成模块,方便复用注意必须指定第二个参数,否则变成找到已经定义的模块请参照资料-备课代码-20-module.html理解语法语法: angular.

0评论2023-03-08579

Angular 核心概念2
自定义指令指令增强了 HTML,提供额外的功能内置的指令基本上已经可以满足我们的绝大多数需要了少数情况下我们有一些特殊的需要,可以通过自定义指令的方式实现普通指令语法div hello-world/divhello-world/hello-world angular.module('myModule', []).contr

0评论2023-03-08934

更多推荐