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

问题描述:

我在将 UI-GRId 与行选择和自定义单元格元素结合使用时遇到问题:

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

示例 plunker 在这里: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.