tags:

views:

268

answers:

1

Hi,

I want to hide/show the form field base on selection from select form field, I used the following code but it didn't hide the #Job_Name. How to acheive this?

{  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
 }

Thanks in advance,

lupind

A: 

Does the event fire at all? Use alert('') to check.

Why do you use tr_#Job_Number - with underscore? Shouldn't it be tr#Job_Number or even just #Job_Number, or better $(formid).find("#Job_Number")?

queen3
The events is being fired, yes.Because I follow as the doc say here http://www.secondpersonplural.ca/jqgriddocs/index.htm.(Dynamic Editing Form) section.
lupind
OK, what about tr/id? Did you try without underscore? You can use FireBug and verify that $("tr#Job_Number") is valid when breakpoint is hit.
queen3
yes I tried without underscore and and verify via Firebug the tr/id is "tr_JobNumber". I can set the value of the input element for tr_JobNumber from the value on selected select but somehow hiding/showing it is not working at all.
lupind
ok it now solved, it should be:$("#tr_Job_Number).hide();
lupind