与ng-grid绑定的双向数据

时间:2015-04-29 10:06:28

标签: angularjs ng-grid

我想将我的ng-grid celltemplate绑定到html文本框(我有ng-grid,它显示数据,下面我要添加一个文本框,这样当我在文本框中键入内容时,值应该在ng-grid的单元格模板中更新。

这是我的html页面:

<div ng-controller="bulkAssign" >

                    <form name="signup_form" method="POST">
                                <div style=" border: 1px solid rgb(212,212,212);
                                        width: 1000px; 
                                        height: 200px;" ng-grid="gridUser">
                                </div>

                                <p><b>Editing grid</b></p>
                                <div class="gridStyle" ng-grid="gridOptions" data-ng-click="testSeletion()"></div>
                                <label>Edit grid from textbox</label>
                                    <input type="number"  name="assignTo" ng-model="assignTo" placeholder="Assign order to"  class="form-control" >


                                </form>     
                                </div>      

这是我的控制器:

$scope.gridOptions = { 
        data: 'names',

        enableCellSelection: false,
        enableRowSelection: true,
        showSelectionCheckbox: true,

        multiSelect: true ,
        columnDefs: [
                     {
                         field: 'orderId', 
                         displayName: 'OrderId', 
                         enableCellEdit: false,
                         cellTemplate:'<div class="ngCellText" ng-class="col.colIndex()"><a ng-click="loadById(row)">{{row.getProperty(col.field)}}</a></div>' 

                    },
                    {field: 'trackingId', displayName: 'trackingId', enableCellEdit: false, cellTemplate:'<div class="ngCellText" ng-class="col.colIndex()"><a ng-click="loadById(row)">{{row.getProperty(col.field)}}</a></div>' },
                     {field: 'orderTitle', displayName: 'OrderTitle', enableCellEdit: false}, 
                     {field:'customerName', displayName:'CustomerName', enableCellEdit: false},
                     {field:'customerContactno', displayName:'ContactNo', enableCellEdit: false},


                     {field:'assignTo', displayName:'assignTo', enableCellEdit:true,cellTemplate:'<input type="number">'}
                     ],

                     selectedItems: $scope.mySelections,

                     filterOptions: $scope.filterOptions


    };

我的问题是在文本框中输入值后,当我点击按钮时,是否可以更新ng-grid celltemplate中的值?

0 个答案:

没有答案