Good afternoon Syncfusion
Is there a suggested method or API I am able to access to get all of the selected rows on my spreadsheet?
I can do this via the element and HTML but it is not very secure. I can't find anything in the spreadSheetObj that flags or triggers a status of selection.
The built-in Delete Row feature is able to access this however there is no information under Delete or Row Selection. I am looking to batch delete selected rows, I will be able to take care of this once I can figure out how to pick these values from the spreadsheet.
https://ej2.syncfusion.com/angular/documentation/spreadsheet/selection#row-selection
Thank you for your support
MCR
Hi Myles Renaud,
Based on your shared information and screenshot, we suspect that you want to delete the selected rows which is discontinuous range which is selected using ‘Ctrl’ key. Currently, we don’t have support to delete/hide rows or columns which are in a discontinuous range. And we have already considered this as an improvement and logged it as a feature. It will be available in any of our upcoming releases. You can communicate and track the status of the feature using the below link from our feedback portal.
Feedback link for tracking purposes: https://www.syncfusion.com/feedback/40489/provide-show-hide-support-with-discontinuous-range-selection-ctrl-key-selection
Meanwhile, we have tried a workaround solution to delete the discontinuous range of rows using the delete method of Spreadsheet by sending the row index as argument to the method. For your convenience, we have prepared the sample and attached below along with the code snippet and video demonstration,
Code snippet:
|
deleteSelectedRows(): void { let selectedRange: string = this.spreadsheetObj.getActiveSheet().selectedRange; //Spit the selectedRange based on a space to find the discontinued selected. let rangeArray: string[] = selectedRange.split(' '); if (rangeArray.length > 1) { //Run the for loop in the reverse order to delete all selected rows properly. for (let i = rangeArray.length - 1; i >= 0; i--) { //Get range indexes. let rowIndex: number[] = getRangeIndexes(rangeArray[i]); //Check whether the selected range is single row. if (rowIndex[0] === rowIndex[2]) { this.spreadsheetObj.delete(rowIndex[0], rowIndex[0], 'Row'); } } } } |
Sample link: https://stackblitz.com/edit/angular-pn6gzp-gcdqzs?file=src%2Fapp.component.ts
Video link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Delete_discontinuous_rows982811436
For more information, please refer the below documentation link and API reference,
Documentation link: https://ej2.syncfusion.com/angular/documentation/spreadsheet/rows-and-columns#delete
API reference: https://ej2.syncfusion.com/angular/documentation/api/spreadsheet/
Kindly, check the above information and get back to us for further validation.