元のコード サンプルは次のとおりです。
function create_button_from_textattribute(fieldname, buttontext, buttonwidth, clickevent) {
functiontocall = clickevent;
crmForm.all[fieldname].DataValue = buttontext;
crmForm.all[fieldname].readOnly = true;
crmForm.all[fieldname].style.borderRight = "#3366cc 1px solid";
crmForm.all[fieldname].style.paddingRight = "5px";
crmForm.all[fieldname].style.borderTop = "#3366cc 1px solid";
crmForm.all[fieldname].style.paddingLeft = "5px";
crmForm.all[fieldname].style.fontSize = "11px";
crmForm.all[fieldname].style.backgroundImage = "url(/_imgs/btn_rest.gif)";
crmForm.all[fieldname].style.borderLeft = "#3366cc 1px solid";
crmForm.all[fieldname].style.width = buttonwidth;
crmForm.all[fieldname].style.cursor = "hand";
crmForm.all[fieldname].style.lineHeight = "18px";
crmForm.all[fieldname].style.borderBottom = "#3366cc 1px solid";
crmForm.all[fieldname].style.backgroundRepeat = "repeat-x";
crmForm.all[fieldname].style.fontFamily = "Tahoma";
crmForm.all[fieldname].style.height = "20px";
crmForm.all[fieldname].style.backgroundColor = "#cee7ff";
crmForm.all[fieldname].style.textAlign = "center";
crmForm.all[fieldname].style.overflow = "hidden";
crmForm.all[fieldname].attachEvent("onmousedown", push_button);
crmForm.all[fieldname].attachEvent("onmouseup", release_button);
crmForm.all[fieldname].attachEvent("onclick", functiontocall);
}
Dynamics Crm 2013 への移行後、readOnly および DataValue プロパティは機能しなくなりました。
私はこのサンプルで方法を試しました:
function create_button_from_textattribute(fieldname, buttontext, buttonwidth, clickevent) {
var btn = '<button id="btn_' + fieldname + '" ' +
' style="width:' + buttonwidth + '" ' +
' class="ms-crm-Button" ' +
' onmouseover="Mscrm.ButtonUtils.hoverOn(this);" ' +
' onmouseout="Mscrm.ButtonUtils.hoverOff(this);" ' +
'>' + buttontext + '</button>';
var ctrl = Xrm.Page.ui.controls.get(fieldname)._control;
ctrl.get_element().innerHTML += btn;
ctrl.get_element().firstChild.style.display = 'none';
Xrm.Page.ui.controls.get('new_btnmaj').setLabel('');
ctrl.get_element().childNodes[1].attachEvent('onclick', clickevent);
しかし、行 Xrm.Page.ui.controls.get(fieldname)._control で未定義の要素エラーが発生します
それを機能させるためのアイデアやリードはありますか?