Вопрос

I have to make an invoice application, and I have to use ng-grid.

But I cannot figure out how to take the value that the user will insert into the cell, and use it.

    $scope.myData = [{},{},{}]; /*tre row di default*/
    $scope.gridOptions = { 

      data: 'myData', 
      enableCellSelection: true,
      enableCellEdit: true,
      enableRowSelection: false,
      columnDefs: [{field: 'Numero', displayName: 'Numero', enableCellEdit: true},
      {field:'Descrizione', displayName:'Descrizione'},
      {field: 'CostoUnitario', displayName: 'Costo Unitario', enableCellEdit: true},
      {field: 'Qta', displayName: 'Qta', enableCellEdit: true},
      {field: 'Totale', displayName: 'Totale', enableCellEdit: false},]
    };
 $scope.addRow = function() {
      $scope.myData.push({});
    };

I really don't know how to do this!

Это было полезно?

Решение

Try using row.entity object..

On html side, define your input with ng-model="exapmle" as you probably did.. On angular side, get your textbox value with row.entity.example

An example which i did recently.. Look at last column def column..

$scope.gridOptions = {
    data: 'accounts',
    multiSelect: false,
    showFilter: false,
    showColumnMenu: false,
    showSelectionCheckbox: false,
    showGroupPanel: false,
    showMenu:false,
    showFooter: false,
    enableRowSelection: false,
    columnDefs: [                   
         {field: 'username', displayName: 'Username', width:180},
         {field: 'email', displayName: 'Email', width:250},
         {field: 'role.displayTxt', displayName: 'Role', width:120},
         {field: 'active', displayName: 'Active', width:80},
         {field: '', displayName: ' ', width: 50, 
             cellTemplate: '<div class="grid-action-cell">' + 
             '<a class="btn-link" type="button" title="Edit" ng-href="#/accounts/{{row.entity.username}}">' + 
                '<i class="glyphicon glyphicon-edit" style="left:8px; top:8px;"></i>' +
             '</a>' +
             '</div>'
         }, 
        ]
};
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top