How to show readonly fields in edit form in jqgrid or otherwise show all text from readonly column

jqGrid colModel contains only a multi-line read table defined using the properties below. The content row is longer than the column width, the text is long, so tooltio does not display all the content. Unable to see all content.

I am looking for a way to allow the user to see the contents of entire columns. For example, if a form edit button is clicked, this column content should appear in the edit form as a readonly text field. However, readonly columns are not displayed on the edit form.

How to allow the user to see all the column content?

colModel: [{ "name":"LoggedLongText", "editable":false,"width":539, "classes":"jqgrid-readonlycolumn","fixed":true, "hidden":false,"searchoptions":{"sopt":["cn","eq","ne","lt","le","gt","ge","bw","ew","nc"]}} }] 
+6
source share
3 answers

Is the setting

 editable: true, editoptions: { readonly: "readonly" } 

maybe what you need?

UPDATED: The free jqGrid supports more values ​​for the editable property since version 4.8. The wiki article describes that editable can be a function and supports an additional three string values ​​when using form editing: "hidden" , "disabled" and "readonly" .

+31
source

To display read-only fields, you can try using "disabled:disabled" inside editoptions .

Another option is to use a custom element type that returns a range, as shown below:

 colModel: [ ... {name:'price', ..., editable:true, edittype:'custom', editoptions:{custom_element: myelem, custom_value:myvalue} }, ... ] .. function myelem (value, options) { var el = document.createElement("span"); $(el).val(value); // be sure to escape special characters as necessary. return el; } function myvalue(elem, operation, value) { // just reutrun null or empty string. return ""; } 

I prefer this using " readonly:readonly " because the readonly option wraps the cell input control, the input control still gets focus, which I think is misleading for the user. Using "disabled:disabled" allows you to get an input element better, which is slightly better in terms of usability.

Using span is much better. Interestingly, jqGrid even sends β€œ unsuccessfully ” to the server.

Hope this helps. - jqr

+3
source

To display readonly fields in EditForm, you should try using the {readonly: true} property inside editoptions for the jqGrid column and work.

+1
source

Source: https://habr.com/ru/post/895007/


All Articles