Skip to content

MobileCRM.UI._DetailView.registerClickHandler

rescocrm edited this page May 15, 2023 · 9 revisions

[v8.0] Installs the handler which has to be called when user clicks on the link item.

Arguments

Argument Type Description
item MobileCRM.UI.DetailViewItems.LinkItem An item
callback function(String, String) A callback which is called when user clicks on the link item. It obtains the link item name and the detail view name as arguments.
scope Object A scope, in which the callback has to be called.

This example demonstrates how to register the event handler on the detail link item.

function registerEvent(itemName) {
	MobileCRM.UI.EntityForm.requestObject(function (entityForm) {
		var detailView = entityForm.getDetailView("General");
		var linkItem = detailView.getItemByName(itemName);
		if (linkItem) {
			// The item was already inserted on the form.
			// Just set the value property and bind the handler.
			linkItem.setTypedValue("value", "System.String", itemName); // The type must be set explicitly for LinkItem
			detailView.registerClickHandler(linkItem, onLinkItemClick);
		}
		else {
			// create MobileCRM.UI.DetailViewItems.LinkItem
			linkItem = new MobileCRM.UI.DetailViewItems.LinkItem("SaveLink", itemName);
			detailView.registerClickHandler(linkItem, onLinkItemClick);
			detailView.insertItem(linkItem, -1); // Place the item as the last one.
		}
	}, MobileCRM.bridge.alert);
}
function onLinkItemClick(itemName, detailViewName) {
	/// <param name="itemName" type="String">The name of detail view item which has been clicked.</params>
	/// <param name="detailViewName" type="String">The name of detail view which contains the clicked item.</params>
	MobileCRM.UI.EntityForm.saveAndClose();
}
Clone this wiki locally