how to show readonly fields in edit form in jqgrid or other way to show whole text from readonly column

后端 未结 3 1908
借酒劲吻你
借酒劲吻你 2021-01-12 18:36

jqGrid colModel contains read-only multi line column defined using properties below. Content line lenghts are greater than column width, text is to long so that tooltio does

3条回答
  •  自闭症患者
    2021-01-12 18:58

    To show readonly fields you might try using the "disabled:disabled" inside editoptions.

    Yet another option is to use a custom element type that returns a span as 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 over using "readonly:readonly", because the readonly option wraps an input control around the cell value, the input control still receives focus, which I think is misleading to the user. Using "disabled:disabled" keeps the input element from receiving better, which is slightly better, in terms of usability.

    Using a span is much better. Interestingly, jqGrid sends even "unsuccessful" form controls to the server.

    Hope this helps. -- jqr

提交回复
热议问题