Hi,
I'd like to be able to build my RowContextMenu at run-time based on the row being selected. Based on values in the selected row, I need to be able to modify my row context menu and JS calls to it.
How can I achieve this?
Thanks!
Hello Khaled,If you like you can set autopostback flags to true on RowSelection Change. This way everytime you go to the server you will be able to clear the items from the menu and add new one. What I would suggest to use only javascript and add all the necessary items in the context menu. Then on popping of the menu to disable or make invisible those items which should not be available like ContextMenu.getItems().getItem(0).set_visible(true) or ContextMenu.getItems().getItem(0).set_enabled(true) .Please let me know if those suggestions sound reasonably to you and if you face any issues implementing them.
I'm not sure I understand.Can you provide sample code?
I can set the following:
<ig:Selection CellClickAction="Cell" CellSelectType="None" ColumnSelectType="None" RowSelectType="Multiple"> <AutoPostBackFlags RowSelectionChanged="true" /> </ig:Selection>
But then, what event do I capture client side to do this?
Hello Khaled,Is this issue occuring with the sample i provided or it is occuring in your project? If it is the second one please provide an isolated sample which reproduces the issue. Also are you with the same build as the sample.
Hey,
I had to modify my code a around a little more. Now the problem is no context menu comes up at all. Not even the browser's. I attached a sample to demonstrate. Any code I commented out in the GridMouseDown event I did so because it came up with a JS error. This code uses the Northwind Database. You may have to edit the ConnectionString in the .cs file.
Thanks for your help!
I should also note that I need the right click the automatically select the row it happens on even if no row is currently selected.
Thank you.
Hello Khaled,I took a quick look at your project. Did you have the chance to look at my working attachment? Since you are modifying another control which is outside the grid no changes would be saved. In my sample I disabled the ajax of the grid and put both – menu and grid in an update panel to ensure that when I update the menu from the grid’s event the changes will be saved. Please take a look at the following page - http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.aspx Another point is - no need to call Databind everytime the datarourse is set. The grid is calling automatically databind after you set datasource in page load. Databind should be called manually if you are setting a new datasource after the binding events have passed (render for example) or when you are making visual changes – for example hiding a column after the grid is bound. Your selection changed event was not triggered. Actually your selection was not persisted. The reason for this is that you call ClearDataSource to the grid which has to be called only when you are setting another datasource not the present one - http://help.infragistics.com/NetAdvantage/ASPNET/2012.2/CLR4.0?page=Infragistics4.Web.v12.2~Infragistics.Web.UI.GridControls.WebDataGrid~ClearDataSource.html . When you call this method you are clearing all the selection activation and other data which is persisted from our grid for the present datasource. After you remove this method the grid will start invoking the row selection changed server event in which you will be able to add the items in the menu. IF you follow my advice an add the grid and the menu in an update panel the menu will start to update its items when they are set from another control. Please note that the context menu is not showed if it does not have items at all and this is by desing. Regarding the row selection. Currently it is not possible to select a row because you have set cell click action to be cell not row so the property rowselectype – multiple is actually not working because you cant select a row.
Hello Khaled,Please let me know if you have any further questions regarding this issue.
Hello Khaled,Please take a look at the attached sample which is changing visibility of the items on the client.
Hi Nikifor,
Based on my project needs I have to implement a different solution. I had the WebDataMenu items created in the markup. During the MouseDown event, I would check certain conditions in my grid and hide menu items as needed.
Thanks.