如何动态更改(删除或添加)表单选项:{elmprefix:“*”}
我正在 beforeShowForm
函数中控制 colProp
所需的值,并且它工作正常。我的问题是 formoptions:{elmprefix:"*"}
不起作用。 我做错了什么吗?还有其他方法吗? 我的代码片段是这样的
$grid2.jqGrid('navGrid', '#pager',
{ edit:true, add:true, del:true, search:false, view:true, cloneToTop:true},
{ // edit options
beforeShowForm: function(form) {
$("#list").setColProp('Done_Date',
{editrules:{required:true}, formoptions:{elmprefix:"*"}});
$("#list").setColProp('Outcome',
{editrules:{required:true}, formoptions:{elmprefix:"*"}});
},
editCaption:"Edit Record",
edittext:"Edit",
closeOnEscape:true,
savekey: [true,13],
errorTextFormat:commonError,
width:"550",
reloadAfterSubmit:true,
bottominfo:"Fields marked with (*) are required",
top:"60",
left:"70",
closeAfterEdit:false
},
提前致谢 标记
I'm controlling the colProp
required value in the beforeShowForm
function and its working fine. My problem is the formoptions:{elmprefix:"*"}
does not take effect.
Am I doing something wrong? Is there another way to do it?
My code snippet is this
$grid2.jqGrid('navGrid', '#pager',
{ edit:true, add:true, del:true, search:false, view:true, cloneToTop:true},
{ // edit options
beforeShowForm: function(form) {
$("#list").setColProp('Done_Date',
{editrules:{required:true}, formoptions:{elmprefix:"*"}});
$("#list").setColProp('Outcome',
{editrules:{required:true}, formoptions:{elmprefix:"*"}});
},
editCaption:"Edit Record",
edittext:"Edit",
closeOnEscape:true,
savekey: [true,13],
errorTextFormat:commonError,
width:"550",
reloadAfterSubmit:true,
bottominfo:"Fields marked with (*) are required",
top:"60",
left:"70",
closeAfterEdit:false
},
Thanks in advance
Mark
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用 beforeInitData 而不是
beforeShowForm
能够在创建表单期间动态更改elmprefix
设置。此外,您应该使用 recreateForm: true 属性。我建议您阅读这篇文章,其中描述了如何格式化问题内的代码。
The you should use beforeInitData instead of
beforeShowForm
to be able to changeelmprefix
setting on the fly during creating of the form. Additionally you should use recreateForm: true property.I would recommend you to read the post which describes how to format the code inside of the question.