what is wrong with my block to delete the listview selection as its deleting sometimes all and sometimes the first row not the specific one?
and here is the delete script
//DELETE SINGLE RECORD
else if (e.parameter.func == "Delete") {
var record = e.parameter.id;
var ss = SpreadsheetApp.getActive();
var sh = ss.getSheets()[0];
sh.deleteRow(parseInt(record) + 1);
return ContentService.createTextOutput("Success");
i just took it from a project but if i can exclude spreadsheetID and a sheetName it will be better as its already the first sheet and all i want to delete the selected row
i tried that script but still deleting the first row and i need to delete the selected listview selectionindex one
https://script.google.com/macros/s/your-script-id/exec?id=Num&func=Delete
and that one as well https://script.google.com/macros/s/your-script-id/exec?func=Delete&id=5
AIA file is free for checking, you can check all the functions of the extension and can purchase only after completely satisfied. I have developed this extension for ease of everyone, so that nobody has to face difficulty wit spreadsheet's read write operations with apps script.
I will have another go too, keeping things as simple as possible
Sheet1 of Spreadsheet
Script
function doGet(e) {
if ( e.parameter.func == "deleteRow" ) {
var ss = SpreadsheetApp.openById(e.parameter.sheetID);
var sh = ss.getSheetByName(e.parameter.gridName);
sh.deleteRow(parseInt(e.parameter.row));
return ContentService.createTextOutput('Row ' + e.parameter.row + ' Deleted');
}
}
Blocks
(note the textbox is multiplied by 1 to make it a number - not essential, but could help in some circumstances if you forget to use "parseInt" in your script)
Screen Before
Screen After
Spreadsheet After
You see that row 4 of the spreadsheet that contained [3,Bob] has been deleted.
Note: you now have a new row 4 [4,Nick]. (maybe this is your issue, that you are attempting to delete a specific record and not a row?)
i have used the same code used in this site, i always suggest the same cide to one all. That was easy to connect app to gsheet. Credit to @TIMAI2 only.
You mean particular cell? Only the selected cell instead of complete row??
By the way do you get above such error on selecting an item in listview? If so how did you set values into the liatview? Show us your Complete code regarding this to help you better
Once you delete as i did in the eg pls refresh your list view