简体   繁体   English

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

[英]AngularJS ui-grid editableCellTemplate: 'ui-grid/dropdownEditor'

I am using "ui-grid - v3.2.6" 我正在使用“ui-grid - v3.2.6”

I have a grid with 6 columns, and out of that 2 columns ('Impact Value' and 'Effective Start Date') are editable. 我有一个包含6列的网格,其中2列(“影响值”和“有效开始日期”)可编辑。

'Impact Value' is using editableCellTemplate: 'ui-grid/dropdownEditor' '影响价值'正在使用editableCellTemplate:'ui-grid / dropdownEditor'

Data is displayed properly in the grid. 数据在网格中正确显示。 But, when i double click on any of the editable columns. 但是,当我双击任何可编辑的列时。 I see weird behavior , please see the screen shots. 我看到奇怪的行为,请看屏幕截图。 I would like to know what i am doing wrong that i am not seeing a dropdown when i double click on that column. 我想知道我做错了什么,当我双击该列时,我没有看到下拉列表。

i followed the ui-grid tutorial link 我按照ui-grid教程链接

 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") }) }]); 
 <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 在此输入图像描述

In the imValues array, you have a value and a label. 在imValues数组中,您有一个值和一个标签。 In the column definition of the Impact values you have these two attributes wrong: 在Impact值的列定义中,您有以下两个属性错误:

editDropdownIdLabel: 'impactValue',
editDropdownValueLabel: 'impactValue',

If I'm right, editDropdownValueLabel attribute indicates what you see when you focus on the cell, whereas editDropdownIdLabel attribute indicates the actual value of the selected option. 如果我是对的,editDropdownValueLabel属性指示您在关注单元格时看到的内容,而editDropdownIdLabel属性指示所选选项的实际值。 Pretty much like the ordinary html tag. 非常像普通的html标签。 So this will work: 所以这将有效:

editDropdownIdLabel: 'value',
editDropdownValueLabel: 'label',

If it didn't work, use this: 如果它不起作用,请使用:

editDropdownIdLabel: 'label',
editDropdownValueLabel: 'value',

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM