2010-02-22 20 views
0

我想隐藏/显示基于选择表单字段的表单字段,我使用了下面的代码,但它并没有隐藏#Job_Name。如何实现这个目标?通过dataEvents隐藏/显示表单字段

{ name: 'Job_Number', 
    index: '`Job #`', 
    editable: true, 
    edittype: 'text', 
    editoptions: { size: 10, readonly: 'readonly'}, 
    editrules: {required: true }, 
    formoptions: { label: 'Job #' }, 
    width: 10, 
    formatter: 'integer', 
    formatoptions: { thousandsSeparator: '' }, 
    searchoptions: { sopt: ['eq','ne','lt','le','gt','ge', 'in', 'ni'] }, 
    align: 'right', 
    sortable: true 
}, 
{ name: 'Job_Name', 
    index: '`Job Name`', 
    editable: true, 
    edittype: 'select', 
    editoptions: { //size: 1, 
       value:{1:'One',2:'Two'}, 
        // dataUrl: 'select', 
        dataEvents: [ 
         { type: 'change', 
         fn: function(formid) { 
           $("tr_#Job_Number").hide(); 
         } 
         } 
        ] 
    }, 
    formoptions: { label: 'Job Name' }, 
    searchoptions: { sopt: ['eq','ne','lt','le','gt','ge', 'cn', 'nc', 'bw', 'bn'] }, 
    align: 'right', 
    width: 150, 
    align: 'left', 
    sortable: true 
} 

由于提前,

lupind

回答

0

请问事件火呢?使用警报('')进行检查。

为什么你使用tr_#Job_Number - 带下划线?它不应该是tr#Job_Number,甚至只是#Job_Number,或更好的$(formid).find(“#Job_Number”)?

+0

事件正在被解雇,是的。 因为我按照doc在这里说http://www.secondpersonplural.ca/jqgriddocs/index.htm.(Dynamic Editing Form)部分。 – lupind 2010-02-22 23:38:51

+0

好的,tr/id呢?你没有下划线试试吗?您可以使用FireBug并确认$(“tr#Job_Number”)在命中断点时有效。 – queen3 2010-02-23 08:12:01

+0

是的,我尝试没有下划线,并通过Firebug验证tr/id是“tr_JobNumber”。我可以根据选定的select设置tr_JobNumber的input元素的值,但不知何故隐藏/显示它根本不起作用。 – lupind 2010-02-23 09:08:54

相关问题