使用formformit的jqGrid编辑基于另一个字段的值禁用字段 [英] jqGrid edit using formedit disable fields based on value of another field

查看:49
本文介绍了使用formformit的jqGrid编辑基于另一个字段的值禁用字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户单击jqGrid中的Edit时,打开的表单将包含一些列表框和文本框.根据列表"框中的值,必须禁用几个文本框或将其设置为仅在加载表单时读取.

When the user clicks on Edit in jqGrid, the form which opens has a few list boxes and text boxes. Depending on the value in a List box a couple of text boxes have to be disabled or set to read only when the form loads.

我已经为列表框上的onChange事件工作,将文本框切换为禁用/启用,但是我正在努力在表单加载时做到这一点.我尝试使用aftershowform,它已经具有一个事件处理程序,因此我创建了另一个事件,例如aftershowform2,并附加了该事件,并且该事件处理程序将触发.但是问题在于,列表框是使用Ajax调用(editoptions的dataurl)动态加载的,并且在用选项填充这些列表框之前会触发aftershowform.加载列表框后是否会触发其他事件?整个应用程序是框架驱动的,很难粘贴代码.

I got the piece working for the onChange event on the listbox to toggle the textboxes to disabled/enabled, but I am struggling to do it on the form load. I tried using the aftershowform, which already has a event handler, so I created another event say for example aftershowform2 and attached this event and the eventhandler fires. But the problem is the listboxes are dynamically loaded using an Ajax call (dataurl of editoptions) and aftershowform fires before these listboxes are populated with the options. Is there any different event which fires after the listboxes are loaded? The whole application is framework driven, and it is hard to paste the code.

推荐答案

我看到了许多可以用来实现需求的方法.

I see many ways which you can go to implement your requirements.

在我看来,第一个也是最好的一个是编辑选项(请参阅

The first and the best one in my opinion would be the usage of dataEvents of the editoptions with the type:'change' (see this answer as an example). The corresponding code can be

editoptions: { dataUrl:...,
               dataEvents: [
                   {
                       type: 'change',
                       fn: function(e) {
                            var v=$(e.target).val();
                            alert(v); // do something with selected item value
                       }
                   }
               ]
             }

dataEvents定义的功能的绑定将在服务器成功返回select包含内容之后.

The binding to the functions defined by dataEvents will be after the successful return of the select contain from the server.

另一种方法是修改当前的实现,以便将 jQuery.bind 替换为 jQuery.live (请参阅代码模板

Another way would be modify your current implementation so that you replace jQuery.bind to jQuery.live (see a code template here).

这篇关于使用formformit的jqGrid编辑基于另一个字段的值禁用字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆