27.06.2009, 20:05 | #1 |
Участник
|
mscrm4ever: CRM 4.0 Adding a helper button to text fields
Источник: http://mscrm4ever.blogspot.com/2009/...n-to-text.html
============== Sometimes you want to attach a click event to a text field. Since CRM does not provide a way to associate a button to a field you need to implement the functionality using JavaScript. The following TextHelperButtom object helps you achieve that goal on any given text field. When creating an instance of the TextHelperButtom set the following parameters: Image width – This is used to adjust the image positioning. MouseOver image URL – This image that is displays when you go over the button. MouseOut Image URL – the default image URL Click – a function to call when the user clicks on the image. Paste the code inside the entity onload event and enjoy... TextHelperButton = function(fieldId) { var fldButton = this; fldButton.Field = crmForm.all[fieldId]; if (!fldButton.Field) { return alert("Unknown Field: " + fieldId); } fldButton.Click = null; fldButton.Image = new ButtonImage(); fldButton.Paint = function() { var field_d = document.all[fldButton.Field.id + "_d"]; if (field_d) { field_d.style.whiteSpace = "nowrap"; field_d.appendChild(fldButton.Image.ToObject()) } } fldButton.MouseOver = function() { event.srcElement.src = fldButton.Image.MouseOver; } fldButton.MouseOut = function() { event.srcElement.src = fldButton.Image.MouseOut; } function ButtonImage() { this.MouseOut = ""; this.MouseOver = ""; this.Width = 21 this.ToObject = function() { var img = document.createElement("IMG"); img.onmouseover = fldButton.MouseOver; img.onmouseout = fldButton.MouseOut; img.onclick = fldButton.Click; img.src = this.MouseOut; var cssText = "vertical-align:bottom;"; cssText+= "margin:1px;"; cssText+= "position:relative;"; cssText+= "right:" + (this.Width + 1) + "px"; img.style.cssText = cssText; return img; } } } function OnCrmPageLoad() { var actnButton = new TextHelperButton("name"); actnButton.Image.Width = 21; //integer actnButton.Image.MouseOver = "/_imgs/lookupOn.gif"; actnButton.Image.MouseOut = "/_imgs/lookupOff.gif"; actnButton.Click = Accountnumber_Click; actnButton.Paint(); } function Accountnumber_Click() { alert('Account Number Field Clicked'); } OnCrmPageLoad(); Источник: http://mscrm4ever.blogspot.com/2009/...n-to-text.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|