Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
formedit disable fields based on value of another field
12/08/2011
02:01
Avatar
maggie
Member
Members
Forum Posts: 49
Member Since:
17/12/2008
sp_UserOfflineSmall Offline

I use form edit. I want to disable a field ('Date of Lab Confirmed Diagnosis') based on the value of another field ('Report Type'). The field 'Report Type' data type is select. I use dataevents "change". But I don't know the syntax of disabling a field.

Please see my codes below. Any help is highly appreciated!

-Maggie

jQuery(document).ready(function(){
      jQuery("#communicableDiseaseGrid").jqGrid({
           url:'servlet/communicableDiseaseByDateGrid',
           datatype: 'xml',
           colNames:[

                'Report Type',
                'Date Time of Report to HD',
                'Date of Lab Confirmed Diagnosis'
                ],
           colModel :[
              {name:'reportType',
               index:'reportType', 
               editable:true,
               edittype:'select',
               editoptions:{
               value:{'Active_Report':'Active_Report', 'Information_Request':'Information_Request'},
              dataEvents :[
              { type: 'change',
              fn: function(e) {
                                   var thisval = $(e.target).val();
                                   if (thisval=="Active_Report") {
                                          alert ("it is Information_Request, diable Date of Lab Confirmed Diagnosis ");
                                           //how to disable the field  'Date of Lab Confirmed Diagnosis'?
                                                    //?????
                           
                                   }
           }//end func
           } // end type
          ]  // dataevents
               }
          },
          {name:'dateTimeHD', 
            index:'dateTimeHD',  
            sortable:true, 
            sorttype: "date",
            editable:true,
            editrules:{required:true}
          },
             
           {name:'dateLab',
               index:'dateLab', 
               sortable:false,
               editable:true}],
          

          viewrecords: true, 
          caption: 'Communicable Disease'
            }).setGridHeight(150); 

$("#communicableDiseaseButtonEdit").click(function(){
       var gr = jQuery("#communicableDiseaseGrid").jqGrid('getGridParam','selrow');
       if( gr != null ) {
        jQuery("#communicableDiseaseGrid").editGridRow(
         gr,
         {   top: 0,
             left: 0,
             width: 500,
             height:280,
             modal:true,
            drag: true,
            editCaption:  'Edit Record',
            bSubmit: "Submit",
            bCancel: "Cancel",
            url:'servlet/communicableDiseaseByDateGrid?userAction=update',
           processData: "Processing...",
           closeAfterEdit:true,
          reloadAfterSubmit:true,
         }
       
        });
       }
       else alert("Please Select Row");
     });
  

12/08/2011
16:37
Avatar
djkuddel
Member
Members
Forum Posts: 25
Member Since:
01/08/2011
sp_UserOfflineSmall Offline

Hi,

to hide and show column you can use a click event

to Hide a column you can use e.g. this

jQuery("#button").click( function() { jQuery("#list").jqGrid('navGrid','hideCol',"column"); });

to show a column you can use e.g. this

jQuery("#button").click( function() { jQuery("#list").jqGrid('navGrid','showCol',"column"); });

I hope it helps you.

Best Regards,

DJ

12/08/2011
17:40
Avatar
maggie
Member
Members
Forum Posts: 49
Member Since:
17/12/2008
sp_UserOfflineSmall Offline

Hi DJ,

Thanks for your help. I've tried it but it doesn't work. I want to disable/enable  (or show/hide) a field on the edit form when the selected value of a select list are changed. Is that doable?

Thanks, Maggie

13/08/2011
00:54
Avatar
maggie
Member
Members
Forum Posts: 49
Member Since:
17/12/2008
sp_UserOfflineSmall Offline

I've got a solution:

{name:'reportType',
               index:'reportType',
               sortable:false,
               editable:true,
               edittype:'select',
               editoptions:{
               value:{'Active Report':'Active Report', 'Information Request':'Information Request'},
                dataEvents :[
       { type: 'change',
         fn: function(e) {
                          var thisval = $(e.target).val();
                         // alert ("value: " + thisval);
                         
                          if (thisval=="Information Request") {
                           //disable the field dateLab

                           $('#dateLab').attr('disabled', 'true');
                           
                          }
                         
                          if (thisval=="Active Report") {
                           //enable the field dateLab

                           $('#dateLab').removeattr('disabled');

                          }
                         
                        }//end func
       } // end type
       ] // dataevents
               }
              },

 Cheers,

Maggie

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
60 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information