0

I am developing a web application using JSP & Servlet (IDE: Eclipse, Database: Oracle10). I am using jqGrid to display records in tabular format.

I want to set combobox readonly in Edit dialog.

colNames & colModel

colNames:['User Name', 'Seq No.'],
colModel:[
            {name:'USER_ID',index:'USER_ID', width:200,sortable:true,editable:true,edittype:"select", editoptions: {maxlength: 20,dataUrl: 'ServletName?action=comboUserID'}},
            {name:'SEQUENCE_NUMBER',index:'SEQUENCE_NUMBER', width:50,sortable:true, editable:true, editrules: { required: true, number:true},editoptions: {size:4,maxlength: 2}}
         ],

pager code

).navGrid('#pager10_d1',{cloneToTop:true,edit:true,add:true,del:true,view:true,search: true},
                {
                    width:350,
                    modal:true,
                    jqModal: false,
                    savekey: [true,13],
                    closeOnEscape:true,
                    mtype:'POST',
                    closeOnSubmit: true,
                    recreateForm: true,
                    editurl:'MyServletName',
                    editData:
                    {
                        action: 'userRolesUPDATE',
                        userID: function () {return userID;}
                    },
                    beforeShowForm: function(form)
                    {
                        $('#USER_ID',form).attr('readonly','readonly');
                    }

                }
                //add dialog and other dialog code here
                );

I am refering to this answer by Oleg , but on my form it is not working, combobox is still editable. The Same code works for other Field in the grid, but it is not working for combobox. So let me know if there is any mistake in my code.

Community
  • 1
  • 1
Bhushan
  • 6,151
  • 13
  • 58
  • 91

1 Answers1

1

I think that <select> (combobox) can't be readonly. You can disable it instead using

$("#USER_ID", form).prop("disabled", true);

or

$("#USER_ID", form).attr("disabled", "disabled");

if you use old version of jQuery (before 1.6).

Oleg
  • 220,925
  • 34
  • 403
  • 798