angularjs – 如何在ng-grid中制作复选框单元格编辑模板?

前端之家收集整理的这篇文章主要介绍了angularjs – 如何在ng-grid中制作复选框单元格编辑模板?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我是ng-grid的新手.我正在学习带有编辑模板选项的ng-grid.我创建了带有编辑复选框选项的网格.但我不知道如何在编辑复选框后获得该网格中的值?谢谢.

这里JSfiddle.

var myapp = angular.module('myapp',["ui","ngGrid"]);

myapp.controller('myctrl',function($scope,$http) {

    $scope.testInfo= "TestInfo";

  $scope.data = {
    persons: [],selected:[],load: function () {
      $http.get("/echo/json/").success(function(data) {
      $scope.data.persons = [
          {id:1,name:"Max",number:51323.512,value:'on'},{id:2,name:"Adam",number:7245.2,{id:3,name:"Betty",number:828,value:'off'},{id:4,name:"Sara",number:23452.45182,value:'on'}
          ];

        $scope.data.selected[0] = $scope.data.persons[0];

      });
    }
  };

   var cellTemplate = "<div ng-class=\"'ngCellText colt' + $index\">"
                    + " <span ng-cell-text>{{COL_FIELD}}</span>"
                    + "</div>";
    var cellEditTemplate = '<input type="checkBox" ng-checked="row.entity.value==\'on\'" ng-input="COL_FIELD" /></div>';

  $scope.grid = {
    options: {
      data: "data.persons",selectedItems: $scope.data.selected,multiSelect: false,columnDefs: [
        {field:"id",displayName:"ID"},{field:"name",displayName:"Name"},{field:"number",displayName:"Nummer",cellFilter:"number:2"},{field: "value",displayName:"Value",enableCellEdit : true,cellTemplate : cellTemplate,editableCellTemplate : cellEditTemplate}

        ]
    }
  };



});

<div ng-app="myapp">
    <div ng-controller="myctrl">

      <a class="btn" ng-click="data.load()">Get data!</a>
      <div ng-grid="grid.options" class="grid"></div>
      <ul ng-repeat="item in data.selected">
        <li>{{item}}</li>
      </ul>
    </div>
</div>
你可能已经想到了这一点,但一个可能的选择是在复选框选择器中使用ng-grid生成.它没有显示在主页面上的示例中,而是作为API中的选项列出.
showSelectionCheckBox: true
原文链接:https://www.f2er.com/angularjs/141583.html

猜你在找的Angularjs相关文章