向UI-Grid添加按钮

时间:2016-09-23 18:23:20

标签: angularjs node.js mean-stack ui-grid

ui-grid中,我想自定义一个用于导入csv文件的按钮,而不是该ui-grid中的下拉菜单。我不想在ui-grid中更改任何内容我只想添加一个额外的按钮。因此,它很容易在UI网格上显示。

代码

var app = angular.module('app', ['ngTouch', 'ui.grid', 'ui.grid.selection', 'ui.grid.exporter', 'ui.grid.importer']);

app.controller('ViewController', ['$scope', '$http', 'uiGridConstants', function ($scope, $http, uiGridConstants) {

  $scope.gridOptions = {
    enableGridMenu: true,
importerDataAddCallback: function ( grid, newObjects ) {
    //   $scope.data = $scope.data.concat( newObjects );
    $scope.data = newObjects;
    console.log($scope.data);    
    $http.post('/save', $scope.data).then(function(data){
    console.log(data);
      $http.get('/save')
  .success(function(data) {
      $scope.gridOptions.data = data;
    });
    });
  },
    onRegisterApi: function(gridApi) {
            $scope.gridApi = gridApi;
    }
  }

$scope.gridOptions.columnDefs = [
    {name:'name'},
    {name:'age'},
    {name: 'marks'}
  ];   
  $http.get('/save')
  .success(function(data) {
      $scope.gridOptions.data = data;
    });
}])


<div ng-controller="ViewController">

  <div ui-grid="gridOptions" ui-grid-importer ui-grid-selection ui-grid-exporter  class="grid">
    </input>

  </div>
</div>

0 个答案:

没有答案