How would I get the actively or just clicked menu item on the server.
From the MenuItemClicked event, it is easy to check the WebMenuItemEventArgs.Item property. However, I need to get it from a different event.
In my case, its when a UltraWebGrid RowBatch event has fired. In certain cases we want the rowbatch event to abort. For instance, if the user clicks File->Cancel in the UltraWebMenu, the RowBatch events will fire and we want to check to see which Item was selected so we can abort the process.
How can I get the currently selected item in the UltraWebMenu.
I tried setting it from the clientside events and storing it in a hidden field. But the hidden field isn't getting the value I assign it before the grids RowBatch events are fired.
If I could just access the selected item in the UltraWebMenu???
Yes, this indeed is a hack, but I believe it is a good solution. PostBack event handlers fire always after Page_Load and this is when the selected item on server actually changes, so it is hard to sync that with other page lifecycle events like grid binding (which typically occurs earlier in the cycle).
So I really like your approach. I can probably suggest something similar to what you have implemented - the idea is from another client of ours (we have a great community) and for another product, but I believe same principles may apply here as well.
Oscar's idea is to handle the CSOM before click event and store the item in a hidden variable, which is then immediately available and correct in each event of the page lifecyle, not only after Page_Load.
You can find Oscar's solution and some sample code here:
http://forums.infragistics.com/forums/t/11288.aspx
Sadly, we couldn't use the rowbatch events because we couldn't figure out a way to prevent them from processing the grid changes on every single postback. Our applications have a lot of functionality and many of the postbacks shouldn't be applying grid changes.
I wasn't working on this personally, but another developer ended up creating another hidden column that acted like Grid Rows DataChanged property and added clientside code to set this column. He then looped on the grid to read this column (only when user is saving). Hardly ideal, but its what he ended up having to do. Not sure if he could of just used the DataChanged property or not (maybe its readonly). Either way they worked around the issue with a hack of sorts.
I appreciate the suggestions...
Hello,
You can take a look at this link:
http://forums.infragistics.com/forums/p/10884/41864.aspx#41864
Hope this helps.
I guess you are handling one of the server side events to update your data: UpdateCellBatch, AddRowBatch, DeleteRowBatch or pdateRowBatch.
Inside those events you get the grid rows that were changed, added or removed and then you update your datasource accordingly. Do not commit the changes yet!
When the ItemClicked event fires, if the item was "cancel", just discard the changes and reload your datasource. Maybe you'll have to rebind the grid to discard the changed/added grid rows.
If the Item that was clicked is "Ok" go ahead and commit your changes, then rebind so the grid gets the new changes.
I recommend the samples "Grid/Editing Data/Row Updating" and "Grid/Editing Data/Database Updating" from the samples page:
http://samples.infragistics.com/2008.2/webfeaturebrowser/default.htm
Initially, I thought you meant MenuItemClicked client-side event. Meaning, in clientside event, put it in viewstate. After researching this I see its not possible. Then I read over your post again and you mean MenuItemClicked Server-Side event. At this point, it is to late as the grids batch update methods have already been fired.
We even tried putting it in a hidden field (setting hidden field in client-side menu event) but the hidden field hasn't yet been populated when the Batch Update/Delete are fired. One would think all control viewstate would of been binded back to the control?
I thought about trying to set a grid property with the selected menu item but can't find a property I can set using CSOM. Their is a grid.bands.tag that would be perfect but I can't figure out how to set it in CSOM.
So it comes down to, if there was just a way on the server to get the currently selected menu item. Isn't there any property in the Menu that specifies which Item is active or selected?