Hi,
i m using WebDataMenu when binding some images to DataMenuItem when i click on DataMenuItem where Key="Add" it is firing below mentioned java script code but oItem.Key is giving undefined. how to get the oItem.Key value in the below javascript code ?
<ig:WebDataMenu ID="WDM" height="22px" itemspacing="0" itemwidthdefault="25px" tabindex="0" runat="server" OnItemClick="WDM_ItemClick" Width="100%"> <AutoPostBackFlags ItemClick="On" /> <GroupSettings Orientation="Horizontal" /> <ClientEvents ItemClick="WDMEditToolbarButtonClicked" /> <ItemSettings CssClass="ItemCssClass" SelectedCssClass="ItemSelectedCSS" HoverCssClass="ItemHoverCSS" /> <Items><ig:DataMenuItem ImageUrl=".new.gif" Key="Add"></ig:DataMenuItem> <ig:DataMenuItem ImageUrl="edit.gif" Key="Edit"></ig:DataMenuItem> <ig:DataMenuItem ImageUrl="copy.gif" Key="Copy"></ig:DataMenuItem> <ig:DataMenuItem ImageUrl="delete.gif" Key="Delete"></ig:DataMenuItem> </Items>
</ig:WebDataMenu>
JavaScript Code:-
function WDMEditToolbarButtonClicked(oToolBar, oItem, oEvent) { if(oItem.Key == "Add")
{ alert(oItem.Key); }
}
Hi Tsanna,
thanks for the help , using your sample code i m able to set the disabled images in DataMenuItems.
Code for Reference to Others:
function wdm_init(sender, e) {var getItemscount = sender.getItems().get_length(); for (var i = 0; i < getItemscount; i++) { var MenuItemText = $find("WDM").getItems().getItem(i); if (!MenuItemText.get_enabled()) { if ($find("WDM").getItems().getItem(i).get_key() == "btnPreview") { MenuItemText.get_element().children[0].children[0].src = "../Images/preview_disabled.gif"; } else if ($find("WDM").getItems().getItem(i).get_key() == "btnUpdate") { MenuItemText.get_element(WDM.children[0].children[0].src = "../Images/submit_disabled.gif"; } else if ($find("WDM").getItems().getItem(i).get_key() == "btnCancel") { MenuItemText.get_element().children[0].children[0].src = "../Images/cancel_disabled.gif"; } } }
Thanks
Ravi
Thanks for the help, this issues has been resolved for now.
Regrads
Hi Ravi,
Can I help with something else?
Regards,
Tsanna
Hello Ravi,
In WebDataMenu CSOM there is no "DefaultImage" property available. The only way to access the respective item's image or set a new one on the client is through
get_element() method which returns the html element representation of this item on the client , for instance: eventArgs.getItem().get_element(). This will return <li> tag, however you need to access the <img> tag which the image source is set to: eventArgs.getItem().get_element().children[0].children[0].src. If you have any further questions, please let me know.
Can you reply for above post.