2010-02-22 71 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