How to detect single cell change in AgGrid when using full row editing? - ag-grid-angular

I am using AgGrid 25.0.1 Enterprise version and typically use editType=fullrow in my application. However I would like to be able to detect when a user changes the value of one cell and then tabs to another, so that I can update one of the dropdowns. There is a callback cellValueChanged but it only fires when row editing stops and then it sends all the events at one time. I would like to know when a cell loses focus before actually saving the row. Is this possible?
For background, if I don't use fullrow editing I can get a cellValueChanged event as each cell is changed but then I would have to make a separate HTTP call to save the results for each cell or create some workaround to wait until the user says it is OK to save all the changes.

Related

google sheets hide rows for 1 user

I've inserted a script to hide row when user click on a button in a googlesheet document.
This document is opened simultanously with multiple users.
My problem, when a user click on the button, rows are hiden for all users.
Is there a possibility to limit the action on the user who click the button?
here is the code to hide row:
activeSheet.hideRows(rowStart,rowCount)
thanks a lot for your help
Cyrille
Every simultaneous user sees the spreadsheet at the same state. The only exception is with filter views that can show the sheet with some rows hidden, and in a different sort order.
Unfortunately, I do not think that filter views can be configured programatically. They are managed by client code in the user's browser, while Apps Script runs on Google's servers and consequently has no access to filter views.
One workaround, a bit clumsy though, is to insert links in the frozen section of the sheet to easily switch between filter views. See the Filter views example spreadsheet for an illustration. This works well but the filter views need to be defined in advance, and that cannot be done programatically.
Use Fiter Views to allow each user getting different partial view at the same time. https://support.google.com/a/users/answer/9308952?hl=en

Is it possible with GAS to automatically send emails when a data validation cell is changed without triggers?

Essentially I have a template of a sheet that is copied and filled out by others to make a request, and then their copy is passed between multiple people for approval based on its status, which is represented by a list of items. I'm trying to add a script to the sheet so that when the value in the status cell is changed, it automatically emails the necessary people to notify them of the status change.
The only way I've found to do this so far is to have an onEdit trigger manually added that checks whether the edited range matches the cell's range, and if so, send the email with the new value held in the cell. Ideally, I would be able to incorporate this into the built-in onEdit(e) simple trigger, but I believe that one of the restrictions included with the simple triggers is that they can't be used to send emails, as it would not send the emails until I added the manual trigger.
My problem is that when other people make a copy of the template, the manually added trigger is lost, so the onEdit function no longer properly sends the email. I was hoping that I could set up this trigger in onOpen(e), but it turns out that creating triggers is also a restricted operation for the simple triggers.
I'm trying to find the easiest way to retain the ability to email when the status is changed. I know I could also just make a button next to the status cell, but my boss is really pushing for it to be automatic to changing the status. Thanks!

Re-applying filters in a Google Drive spreadsheet

I've got a Google Drive spreadsheet that's acting as a to-do list. There's a column for whether I've completed the item represented by a row; when I have, I mark that column as complete. Since I don't need to see items I've completed, I've set a filter (via the toolbar icon plus the pull-down buttons that appear on each column's first cell) that hides anything marked as complete.
When I mark a row as complete, that row stays in my (filtered) list despite the fact that it no longer meets my filter. I'd like it to immediately get filtered when that cell is edited, which seems like it should be easy to do with a trigger, except I have no idea how to force the filter to re-evaluate itself from a script. Sorting doesn't do the trick (I tried that already); is there a way to programmatically force the re-evaluation of the filter?
Unfortunately Apps Script cannot interact with Sheet filters (yet). You may want to star this feature request here, to receive updates and kind of vote for it.

Sort events in google scripts

Is it possible to intercept the range sort event? For example when user select a range, select sort range, click on sort, I need intercept the sort event. The business problem that I am trying to resolve is, if user doesn't include a particular col for sort, I want to either warn the user or include the required col in the sort.
Please let me know. Thanks.
Currently this is not possible. The events you can use to trigger an Apps Script are quite limited, and they don't behave the way traditional Javascript events do, because they run on the server, not in the users browser. Even if a Sort event was made available, your code likely wouldn't be triggered until the default action was completed and the sorting finished.
You could experiment with the Edit event, that will be triggered any time the spreadsheet values are edited, which may include sorting (I've never tested this). But as I mentioned above, you can't block the edit from occurring, just respond to it's results.
https://developers.google.com/apps-script/guides/triggers/
You could tie the sort you would like to performed to a custom button or script menu command, but you cannot captue a sort event or even disable sort in any sheet where a user has edit rights.
To create a button, follow Insert > Drawing, make a shape (rounded rectangle recommended), save it on the sheet, and use the drawing's drop down menu to assign the script by its name.

How to stop a cell being edited in Google App Script

If a user is in edit mode in a cell in a Google Spreadsheet, that is, the cursor is currently blinking in the cell, then I try to insert a value in that cell via an "add on" (where the user is explicitly stating they want to add a value to the cell being edited), how can I programmatically fire an event to the spreadsheet to tell it to stop editing values so that the value inserts properly?
At present, when I try to set a value while the user is editing that cell, the value passed from the add on isn't recorded in the cell, which is quite reasonable. But, the ability to "commit" changes to that cell, stop the editing, then add my value would be really useful.
You cant send a message to stop cell editing.
However, try using range protection.
Set the cell protected thus the user wont be able to commit her change.
The ui might not reflect this until the user commits (havent tried it).
You might have an issue as to when to remove the protection thou.