Dear Devexpress,
I have implemented your Gridview control into my ASP.NET MVC web application and I have a problem with the context menu.
I have to turn the visibility off, on some of the context menu options depending on a model property.
Here is my example, to clarify:
I added two items to the context menu:
settings.ClientSideEvents.ContextMenu = "OnContextMenuInit";
settings.FillContextMenuItems = (sender, e) =>
{
e.Items.Clear();
e.Items.Add("Módosítás", "modosit");
e.Items[0].Image.Url = "~/Content/images/edit.png";
e.Items[0].Image.Width = 20;
e.Items[0].Image.Height = 20;
e.Items.Add("Készrejelentés", "keszrejel");
e.Items[1].Image.Url = "~/Content/images/commit.png";
e.Items[1].Image.Width = 20;
e.Items[1].Image.Height = 20;
} depending on a model property I would like to hide the second option, before the context menu appears:
(I'm currently trying via javascript, I have implemented the context menu client side event, to catch the context menu init)
function OnContextMenuInit(s, e) {
if (e.objectType == "row") {
JuttKarbGrd.GetRowValues(e.index, 'n_sortipus;', function (data) {
var tipus = data[0];
e.menu.GetItemByName('keszrejel').SetVisible(tipus == 1);
});
}
}
This piece of code turns the option's visibility off, BUT the context menu appears before the end of the ContextMenu event.
I have clicked with right click on a row, where the n_sortipus not equals with 1, and I can see the whole context menu, before the code hides the second option.
1.jpg
After a second it disappears:
2.jpg
Is this a bug? Is there a solution for my problem?
Thanks,
Gergő