I want the user to be able to toggle a checkbox with out having to first select the cell so I use: canToggle:true, editEvent:“click” for each field with a checkbox.
The problem is I have a changed function for the same checkboxes.
The changed function should be called every time the checkbox value changes.
The problem is unless the cell has been selected the changed event does not work.
For the first toggle no changed event, for the second and there after it does fire.
If I remove canToggle:true the changed event works as per-normal. Every time the checkbox is toggled the changed event is fired.
How can I make the canToggle fire the changed event?
I tried putting a cellClick on the listGrid to trigger startEditing() but the toggle happens before cellClick.
canToggle can be used independently of editing, that’s why the value is toggled immediately - entering editing is independent.
You can trigger editing manually via cellClick, but if you do this you should set editEvent:“none” so that the grid no longer enters editing automatically.
In general, look for a ListGrid API for any given task related to the current values of the editors, current errors, etc, rather than trying to use the “form” made available in certain event handlers within the inline editors. That “form” exists only temporarily, during editing, and contains at any given time only the editors that are actually active.
I probably should give some more background as to how I am using it. It could be the case that the entire approach is wrong and I am only patching up one problem to encounter a further problem down the line.
The reason for my approach is I have added myfunc() as a property of formItem.
The main reason was to save writing the same large function in every changed event by making it accessible to all formitems.
The same function is needed by both dynamicsForm and listGrids.
Using my function myfunc() it has no way to detect if it’s a listGrid or a form, so if treats everything like a form.
I can see why cellHasChanges is a better approach to valuesHaveChanged because the form is only temporary in a listGrid and it is unaware of the other cells in the grid and cannot detect changes in them.
I guess what I am really after then is for myfunc() to be able to tell if it’s being used in the context of a form or a listGrid and then depending on this do an if else to choose between cellHasChanges and valuesHaveChanged before continuing with the rest of the function.
Is this possible? or would the only way be to supply the listGird id as a parameter of myfunc()?
Thank you, that has helped to simplify the function from 5 to 3 parameters.
The function basically detects if a dynamicForm or listGird has changes and sets a global array[‘variable’] to true and enables a save button. I know I could use formItem showIf to enable/disable a save button but it seems simpler to use the changed event and it also allows me to use an iButton instead of a formItem of type button.
The reason for this global array is external to the function, if a user tries to navigate away they get a warning about unsaved data only if the data will be destroyed as a result of the action.
In addition the other two optional parameters take a tabsetid and a icon url. Then when a change is detected within a tabSet the icon indicates unsaved data. So it’s very easy to see at a glance any unsaved tabs.
The original toggle problem however still exists but listGrids are now much better at detecting changes.
Eh? Isn’t it solved? Write your function such that it can use ListGrid rather than form APIs as needed, and pass the ListGrid from cellClick as previously indicated.
The value has been changed by toggle but myfunc does not see it. The only way it sees the change is if you toggle a value and then untoggle it - changed event is then triggered.
OK, there was some confusion as our understanding of your requirements evolved.
Since what you’re trying to do is change detection, not just reacting to a toggle, you actually want to fire your code after toggling has occurred. cellClick is too early.