Hi,
One suggestion is that you can check particular value of the Grid cell filtered by the ColumnUninqueName. Then according to that value, it is possible to add the MenuItems as your requirement from client side. I have tried this example by using the Column "ContactTitle" of Northwind database for checking the Grid cell value. I have tried to add MenuItem "Publish" if ContactTitle is "Sales Representative" and adds MenuItem "CheckOut" if the ContactTitle is "Marketing Manager". I hope this will help you.
JavaScript:
<script type="text/javascript"> |
function RowContextMenu(sender, eventArgs) |
{ |
var MasterTable = sender.get_masterTableView(); |
var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()]; |
var cell = MasterTable.getCellByColumnUniqueName(row, "ContactTitle"); |
var menu = $find("RadContextMenu1"); |
if(cell.innerText== 'Sales Representative') |
additems("Publish"); |
else if (cell.innerText=='Marketing Manager') |
additems("CheckOut"); |
else if(cell.innerText!='Marketing Manager' || cell.innerText != 'Sales Representative') |
additems(null); |
} |
function additems(str) |
{ |
var menu = $find("RadContextMenu1"); |
menu.trackChanges(); |
menu.get_items().clear(); |
var childItem1 = new Telerik.Web.UI.RadMenuItem(); |
childItem1.set_text("Edit"); |
menu.get_items().add(childItem1); |
var childItem2 = new Telerik.Web.UI.RadMenuItem(); |
childItem2.set_text("Delete"); |
menu.get_items().add(childItem2); |
|
if (str=='Publish' && !menu._findItemByText('Publish')) |
{ |
var childItem = new Telerik.Web.UI.RadMenuItem(); |
childItem.set_text("Publish"); |
menu.get_items().add(childItem); |
} |
else if(str=='CheckOut' && !menu._findItemByText('CheckOut')) |
{ |
var childItem = new Telerik.Web.UI.RadMenuItem(); |
childItem.set_text("CheckOut"); |
menu.get_items().add(childItem); |
} |
menu.commitChanges(); |
} |
</script> |
Thanks,
Shinu.