我正在尝试在代码隐藏中的textfield
或rowexpander
事件监听器中的js中设置AfterRender
的值,但我得到了
无法读取属性' setValue'未定义的
以下是textfield
中的rowexpander
:
<ext:TextField runat="server" Name="notedown" FieldLabel="Note Under" ID="fnotedown">
<Listeners>
<AfterRender Handler="if (form.record.data.Lid != null && form.record.data.Lid != '' )
{
setNoteUnder_js(form.record.data.id);
}" />
</Listeners>
</ext:TextField>
JS:
var setNoteUnder_js = function (fieldid){
#{DirectMethods}.setNoteUnder(fieldid,{
success: function (result) {
#{fnotedown}.setValue(result); //undefined error
}
});
}
代码背后的直接方法:
[DirectMethod]
public string setNoteUnder(int fieldid)
{
DAL.CDMADataContext dc = new DAL.CDMADataContext();
var field = (from f in dc.CFormFields
where f.cid == cid && f.id == fieldid
select f).FirstOrDefault();
string units = null;
if (field.Lid != null && field.Lid != "")
{
units = units + " Gender: " + field.text1 + " Unit: " + field.text2;
fnotedown.SetValue(units); //undefined error
return units;
}
return null;
}