首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AngularJS ui-grid editableCellTemplate:'ui-grid/dropdownEditor‘

AngularJS ui-grid editableCellTemplate:'ui-grid/dropdownEditor‘
EN

Stack Overflow用户
提问于 2016-08-06 05:03:36
回答 1查看 1.8K关注 0票数 1

我使用的是"ui-grid - v3.2.6“

我有一个有6列的网格,其中2列('Impact Value‘和'Effective Date')是可编辑的。

‘'Impact’正在使用editableCellTemplate:'ui-grid/dropdownEditor‘

数据在网格中正确显示。但是,当我双击任何可编辑的列时。我看到奇怪的行为,请看屏幕截图。我想知道我做错了什么,当我双击该列时没有看到下拉列表。

我遵循了ui-grid教程链接。

代码语言:javascript
复制
angular.module('impactMatrixModule')
    .controller("impactMatrixController", ["$scope", "$http", "$rootScope", "uiGridConstants", function ($scope, $http, $rootScope,uiGridConstants) {
        $scope.myExternalScope=$scope;
        
    	var distTypes = [
    	                   { value: 'National Broadcast', label: 'National Broadcast' },
    	                   { value: 'Local Broadcast', label: 'Local Broadcast'},
    	                   { value: 'National Cable', label: 'National Cable'},
    	                   { value: 'National Cable SplitNet', label: 'National Cable SplitNet'},
    	                   { value: 'Local Cable Originator', label: 'Local Cable Originator'},
    	                   { value: 'Regional Cable', label: 'Regional Cable'},
    	                   { value: 'National Broadcast-Pioneer', label: 'National Broadcast-Pioneer'},
    	                   { value: 'Special Event', label: 'Special Event'},
    	                   { value: 'All Other Request', label: 'All Other Request'}
    	                 ];
    	
    	var imValues = [
	  	                   { value: 'Y', label: 'Y' },
	  	                   { value: 'N', label: 'N'},
	  	                   { value: 'I', label: 'I'},
	  	                   { value: 'Y/T', label: 'Y/T'}
	  	                 ];
    	  
    	$scope.gridOptions = {
    		    enableSorting: true,
    		    enableFiltering: true,
    		    enableColumnMenus: false,    	
    		    enableCellEditOnFocus: true,
    		    flatEntityAccess: true,
    		    fastWatch: true,
    		    minRowsToShow: 20,
    		    paginationPageSizes: [20, 50, 100, 500, 1000],
    		    paginationPageSize: 50,

    		    columnDefs: [
    		      { 
    		    	  field: 'distributorDesc', 
    		    	  displayName: 'Distributor Type',
    		    	  enableCellEdit: false,
    		    	  filter: { 
		    		    		 selectOptions: distTypes, 
		    		    		 type: uiGridConstants.filter.SELECT, 
		    		    		 condition: uiGridConstants.filter.EXACT
	    		    		  }
    		      },
    		      { 
    		    	  field: 'functionalArea' , 
    		    	  displayName: 'Functional Area',
    		    	  enableCellEdit: false
    		      },
    		      { 
    		    	  field: 'applicationName', 
    		    	  displayName: 'Application Name',
    		    	  enableCellEdit: false
    		      },
    		      { 
    		    	  field: 'changeType', 
    		    	  displayName: 'Change Type',
    		    	  enableCellEdit: false
    		      },
    		      { 
    		    	  field: 'impactValue', 
    		    	  displayName: 'Impact Value',
    		    	  width: '10%',
    		    	  enableFiltering: false, 
    		    	  enableCellEdit: true,
    		    	  editType: 'dropdown',
    		    	  editDropdownOptionsArray: imValues,
    		    	  editDropdownIdLabel: 'impactValue',
    		    	  editDropdownValueLabel: 'impactValue',
    		          editableCellTemplate: 'ui-grid/dropdownEditor'
    		      },
    		      { 
    		    	  field: 'effStartDate', 
    		    	  displayName: 'Effective Start Date',
    		    	  width: '10%',
    		          enableFiltering: false, 
    		          type: 'date',
                      cellFilter: 'date:"yyyy-MM-dd"'
    		        }
    		    ],
    		    onRegisterApi: function( gridApi ) {
    		      $scope.grid1Api = gridApi;
    		    }
    		  };
    	
            $http.get("/CRST/impactMatrix/distType/all")
                .then(function (evt) {
                    console.log(evt.data.length)
                    $scope.gridOptions.data = evt.data;
                }, function () {
                    console.log("error occured while getting the response from Web service")
                })
             
}]);
代码语言:javascript
复制
<div class="row primaryContainer margin-top15">
	<div id="grid1" ui-grid="gridOptions" ui-grid-pagination ui-grid-edit
		ui-grid-resize-columns class="grid" ></div>
</div>

enter image description here

EN

回答 1

Stack Overflow用户

发布于 2016-08-06 05:34:46

在imValues数组中,您有一个值和一个标签。在Impact值的列定义中,这两个属性是错误的:

代码语言:javascript
复制
editDropdownIdLabel: 'impactValue',
editDropdownValueLabel: 'impactValue',

如果我是对的,editDropdownValueLabel属性表示当您将焦点放在单元格上时看到的内容,而editDropdownIdLabel属性表示所选选项的实际值。非常像普通的html标签。所以这将会起作用:

代码语言:javascript
复制
editDropdownIdLabel: 'value',
editDropdownValueLabel: 'label',

如果它不起作用,请使用以下命令:

代码语言:javascript
复制
editDropdownIdLabel: 'label',
editDropdownValueLabel: 'value',
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38797734

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档