2016-11-03 2 views
0

다음 뷰와 컨트롤러가 mvc 앱에 있습니다. 컨트롤러에서 getFilteredRows() 함수를 호출하는 버튼 ("필터링 된 행 가져 오기")이 있습니다. 버튼을 함수 호출에 사용하기 위해 여러 콤보를 시도했지만 버튼을 호출하지 못하는 것 같습니다. 버튼에 의해 함수가 호출되지 않는 이유를 알 수 없습니다. 도움?ng-click 호출시 설정시 함수가 호출되지 않음

@using ProjectExplorer.Web.Helpers 
@model ProjectExplorer.Web.ViewModels.IProjectHeaderViewModel 

@{ 
    var projects = Model.ProjectHeaders; 
} 

<div> 
    <div class="projectlist" ng-controller="MatchingProjectsController as vm" 
     ng-init='vm.init(@Html.JsonFor(projects))'> 
     <h3>Matching Projects</h3> 
     @Html.ActionLink("Export to Excel", "ExcelExport") 
     <button ng-click="getFilteredRows()">Get Filtered Rows</button> 
     <div id="projectsGrid" ui-grid="vm.projectsTableData" ui-grid-resize-columns ui-grid-selection class="grid gridlist"></div> 
    </div> 
</div> 


(function() { 
    "use strict"; 
    window.app.controller("MatchingProjectsController", MatchingProjectsController); 
    function MatchingProjectsController(uiGridConstants) { 
     var vm = this; 
     vm.init = init; 
     function init(projects) { 
      vm.projects = projects; 
      vm.projectsTableData = _.map(projects, _.partialRight(_.pick, "projectId", "projectServiceNumber", "location", "name", "country", "completionYear", "totalAreaSquareFeet", "totalAreaSquareMeters", "constructionCost", "constructionStatusName", "hasImagery")); 
      vm.projectsTableData = { 
       enableColumnSorting: true, 
       enableFiltering: true, 
       enableVerticalScrollbar: false, 
       columnDefs: [ 
        { 
         field: "projectServiceNumber", name: "Number", width: "6%", 
         cellTemplate: "<div class='text-center ui-grid-cell-contents'>" + 
          "<a href=Details/{{row.entity.projectId}}>{{COL_FIELD}}</a>" + 
          "</div>" }, 
        { 
         field: "name", width: "27%", 
         cellTemplate: "<div class='ui-grid-cell-contents'>" + 
          "<a href=Details/{{row.entity.projectId}}>{{COL_FIELD}}</a>" + 
          "</div>" 
        }, 
        { field: "location", width: "12%" }, 
        { field: "country", width: "8%" }, 
        { 
         field: "completionYear", filters: [ 
          { 
           condition: uiGridConstants.filter.GREATER_THAN_OR_EQUAL, 
           placeholder: "after" 
          }, 
          { 
           condition: uiGridConstants.filter.LESS_THAN_OR_EQUAL, 
           placeholder: "before" 
          } 
         ], name: "Construction Year", width: "8%" }, 
        { 
         field: "totalAreaSquareFeet", filters: [ 
          { 
           condition: uiGridConstants.filter.GREATER_THAN_OR_EQUAL, 
           placeholder: "greater than" 
          }, 
          { 
           condition: uiGridConstants.filter.LESS_THAN_OR_EQUAL, 
           placeholder: "less than" 
          } 
         ], name: "Square Feet", width: "8%", cellTemplate: '<div class="text-center ui-grid-cell-contents">{{ COL_FIELD | number:0 | hide_zero }}</div>' }, 
        { 
         field: "totalAreaSquareMeters", filters: [ 
          { 
           condition: uiGridConstants.filter.GREATER_THAN_OR_EQUAL, 
           placeholder: "greater than" 
          }, 
          { 
           condition: uiGridConstants.filter.LESS_THAN_OR_EQUAL, 
           placeholder: "less than" 
          } 
         ], name: "Square Meters", width: "8%", cellTemplate: '<div class="text-center ui-grid-cell-contents">{{ COL_FIELD | hide_zero | number:0 }}</div>' }, 
        { 
         field: "constructionCost", filters: [ 
          { 
           condition: uiGridConstants.filter.GREATER_THAN_OR_EQUAL, 
           placeholder: "greater than" 
          }, 
          { 
           condition: uiGridConstants.filter.LESS_THAN_OR_EQUAL, 
           placeholder: "less than" 
          } 
         ], displayName: "Cost (USD)", width: "8%", cellTemplate: '<div class="text-center ui-grid-cell-contents">{{ COL_FIELD | hide_zero | currency:undefined:0 }}</div>' }, 
        { field: "constructionStatusName", width: "8%", name: "Construction Status" }, 
        { 
         field: 'hasImagery', 
         name: "Imagery", 
         width: '6%', 
         enableFiltering: false, 
         cellTemplate: '<div ng-show="COL_FIELD" class="text-center ui-grid-cell-contents"><span class="glyphicon glyphicon-ok"></span></div>' } 
       ], 
       enableColumnMenus: false, 
       exporterMenuPdf: false, 
       data: vm.projectsTableData, 
       onRegisterApi: function (gridApi) { 
        vm.gridApi = gridApi; 
       } 
      }; 
     } 
     vm.filteredRows = []; 
     vm.getFilteredRows = function() { 
      var _renderedRows = vm.gridApi.grid.renderContainers.body.renderedRows; 
      vm.filteredRows = vm.gridApi.core.getVisibleRows(vm.gridApi.grid); 
     }; 
    } 
})(); 
//# sourceMappingURL=MatchingProjectsController.js.map 

답변

2

그것은으로 변경해야합니다,

<button ng-click="vm.getFilteredRows()"> 
+0

나는 내가 이것을 시도했다, 그러나이 시간을 근무 맹세! 대단히 감사합니다! –