简体   繁体   English

Ag-grid Angular 2

[英]Ag-grid Angular 2

Is there a way in ag-grid that after selecting the row with the help of checkbox selection and also selecting a row with the help of another cell click selection in such a way that after selecting the rows on cell click event, the previously selected rows remains selected just like in the selection with the help of check-box. 在ag-grid中,有没有一种方法可以在通过复选框选择选择行并在另一个单元格单击选择帮助下选择行之后,在选择单元格单击事件上的行之后,使用先前选择的行保持选中状态,就像在复选框的帮助下一样。 I have an event embedded to the cell of the grid and wants to do some task with the help of the click event but it loses the previously selected rows when a new cell is being clicked. 我有一个嵌入到网格单元格中的事件,想要在click事件的帮助下完成一些任务,但是当单击一个新单元格时,它将丢失先前选择的行。 I want to keep the state of the rows selected earlier. 我想保留先前选择的行的状态。

In your grid-options set rowMultiSelectWithClick to true. 在网格选项中,将rowMultiSelectWithClick设置为true。

https://www.ag-grid.com/javascript-grid-selection/ https://www.ag-grid.com/javascript-grid-selection/

Set to true to all multiple rows to be selected with a single click. 一次单击即可将所有多行设置为true。 Eg if you click select one row, then click select another row, the first row will keep it's selection. 例如,如果您单击选择一行,然后单击选择另一行,则第一行将保持其选择状态。 Clicking a selected row in this mode will deselect the row. 在此模式下单击选定的行将取消选择该行。 This is useful for touch devices where ctrl and shift clicking is not an option. 这对于不能选择ctrl和shift单击的触摸设备很有用。

Can you Try this for multiple selection with current selected row. 您可以对当前选定的行进行多次选择吗? In html, 在html中,

<ag-grid-angular
#agGrid
style="width: 100%; height: 100%;"
id="myGrid"
class="ag-theme-balham"
[columnDefs]="columnDefs"
[rowSelection]="rowSelection"
(rowSelected)="onRowSelected($event)"
[rowMultiSelectWithClick]="true"
(gridReady)="onGridReady($event)"
(click)="getRowSelected($event)"
></ag-grid-angular>

In your typescript component 在您的打字稿组件中

onRowSelected(event) { window.alert("row " + event.node.data.athlete + " selected = " + event.node.selected); }

Hope this will help you! 希望这个能对您有所帮助!

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

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