如何防止在自定义元素上选择行,请在UI-GRID中单击

问题描述:

在使用带有行选择和自定义单元格元素的UI-GRId时遇到一个问题:

I'm facing a problem in using UI-GRId with row selection and custom cell elements:

示例代码查看器位于此处: http://plnkr.co/edit/Ed6s6CGFGXyUzj2cyx2g?p=预览

The sample plunker is here : http://plnkr.co/edit/Ed6s6CGFGXyUzj2cyx2g?p=preview

$scope.gridOptions = { showGridFooter:true,enableRowSelection: true, enableRowHeaderSelection: false };

$scope.gridOptions.columnDefs = [
{ name: 'id' },
{ name: 'name'},
{ name: 'age', displayName: 'Age (not focusable)', allowCellFocus : false },
{ name: 'address.city' },
{ name:'address.pin',cellTemplate:'<select><option value="122002">122002</option><option value="122001">122001</option></select>'}];

您可以看到在单击行时会选择相应的行,而如果您倾向于隐式选择下拉选项,那么也会触发行选择事件,所以我希望在元素上单击像下拉菜单一样,此处的行选择事件不应被触发.

You can see that on row click, the respective row gets selected, while if you tend to select the dropdown options implicitly the row selection event also gets fired, I want that on elements click like dropdown here the row selection event should not be triggered.

请指导.

ui-grid的API允许控制行选择.从另一个线程看这个答案: https://*.com/a/33788459/5954939 .基本上,您可以使用事件rowSelectionChangedisRowSelectable.让我知道您是否需要示例.

ui-grid's API allows controlling row selection. Look at this answer from another thread: https://*.com/a/33788459/5954939. Basically you can use the event rowSelectionChanged or the isRowSelectable. Let me know if you need an example.