Forum



01:33

24/01/2014

I want to add a couple of columns to the edit dialog that are read-only. This is to remind the users which row of data they are editing. (The style I'm currently using highlights the selected row very faintly so it's hard to tell which row of data you are editing.)
Is there a way to add columns to the edit modal and make them read-only?
04:38

22/05/2013

you can use an event like beforeInitData() in the edit function to make the form elements disabled. For example, make the column you want as read only to be a text editable field, then in beforeInitData, set
It will still show up as an input element but it wont be editable. Of course you can also go the extra step of hiding the input element entirely and replacing it with a span of text. I think this will work, but its late and i didn't test it so play with it
val = $("#"+columnname).val();
$("#"+columnname).hide().after('<span>'+val+'</span>');
05:04

24/01/2014

What is columnname if my colModel has a serial number column like this:
colModel: [
{ name: "serialNumber", label: "Serial Number", editable:true},
...
],
Doing
$("#" + "serialNumber").prop('readonly',true);
doesn't work.
Lonewolf217 said:
you can use an event like beforeInitData() in the edit function to make the form elements disabled. For example, make the column you want as read only to be a text editable field, then in beforeInitData, set
$("#"+columnname).prop('readonly',true);It will still show up as an input element but it wont be editable. Of course you can also go the extra step of hiding the input element entirely and replacing it with a span of text. I think this will work, but its late and i didn't test it so play with it
val = $("#"+columnname).val();
$("#"+columnname).hide().after('<span>'+val+'</span>');
15:23

24/01/2014

Here's what I've tried. None of them work:
beforeInitData : function(formid) {
$("#formid").prop('readonly',true);
// $("#jqgh_prodTable_serialNumber").prop('readonly',true);
// $("#jqgh_prodTable_serialNumber").attr('readonly',true);
// $("#prodTable_serialNumber").attr('readonly',true);
// $("#prodTable_serialNumber").prop('readonly',true);
// $("#" + "serialNumber").prop('readonly',true);
}
16:25

22/05/2013

http://www.trirand.com/jqgridw.....ing#events
can you try using beforeShowForm() instead of beforeInitData()
Just got a chance to try it myself and it should work when using the new event.
17:54

24/01/2014

Changing beforeInitData to beforeShowForm doesn't work either. I'll try to find a style that shows the highlighted row more clearly and rely on the users to recognize which row they are editing
This ability to add a read-only column to the edit modal should be added as a feature request for a future release of jqGrid.
06:59

Moderators
30/10/2007

Hello boys,
Why you do this so complex?
There is a more easy way.
If you have read the docs here you should see that this is much easy
colModel : [
...
{name:serialfield, ... editoptions: { readonly : true, /* or readonly : 'readonly' */ ... } ...}
...
]
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
52 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66