Note that there are some explanatory texts on larger screens.

plurals
  1. POjqgrid form editing: add field to the form
    primarykey
    data
    text
    <p>I've been using jqGrid since a couple of months and I'm really happy to do that :)</p> <p>I'm using successfully jqGrid in a ASP.NET web application, everything works correctly. I decided to use jqGrid form editing, 'cause entities have a lot of properties I've to cope with. I understand that if colModel contains 5 cols they appear on the modal dialog form (edit action) if properties have editable:true. Moreover, I can set that 4 properties are visibile and last one is hidden (even if it can appear on the form, by setting edithidden: true).</p> <p>Is there a way I can set 4 properties in the colModel, but there are one,two or much more fields in the popup modal form?</p> <p><strong>EDIT:</strong></p> <p>Please look at this code:</p> <pre><code>ajaxSelectOptions: { type: "POST", contentType: "application/json; charset=utf-8", }, colNames: [ 'ID', 'Code', 'Number', 'Floor (nr.)', 'Descr', 'Type', 'Create by', 'Creation date', 'Status', 'Features'], colModel: [ { name: 'ID', index: 'id', width: 10, align: "center", search: false, sorttype: 'int', searchoptions: { sopt: ['eq', 'ne', 'cn'] }, editable: false, editoptions: { readonly: true} }, { name: 'Code', index: 'Code', width: 20, align: "center", sorttype: 'text', searchoptions: { sopt: ['eq', 'ne', 'cn'] }, editable: false, editoptions: { readonly: true} }, { name: 'Number', index: 'Number', width: 20, align: "center", sorttype: 'int', searchoptions: { sopt: ['eq', 'ne', 'cn'] }, editable: true, editoptions: { size : 20 }, editrules: { required: true } }, { name: 'Floor', index: 'Floor', width: 30, align: "center", sorttype: 'int', search: false, edittype: 'select', editable: true, editoptions: { dataUrl: '&lt;%# ResolveUrl("~/path/to/myCSharpWebService") %&gt;', buildSelect: function (data) { var retValue = $.parseJSON(data); var response = $.parseJSON(retValue.d); var s = '&lt;select id="myid" name="myid"&gt;'; if (response &amp;&amp; response.length) { for (var i = 0, l = response.length; i &lt; l; i++) { s += '&lt;option value="' + response[i]["Id"] + '"&gt;' + response[i]["Descrizione"] + '&lt;/option&gt;'; } } return s + "&lt;/select&gt;"; } }, editrules: { required: true } }, { name: 'Descr', index: 'Descr', width: 40, align: "center", sorttype: 'text', editable: true, editoptions: { size: 10} }, { name: 'Type', index: 'Type', width: 50, align: "center", sorttype: 'text', edittype: 'select', editable: true, editoptions: { dataUrl: '&lt;%# ResolveUrl("~/path/to/myCSharpWebService") %&gt;', buildSelect: function (data) { var retValue = $.parseJSON(data); var response = $.parseJSON(retValue.d); var s = '&lt;select id="myid2" name="myid2"&gt;'; if (response &amp;&amp; response.length) { for (var i = 0, l = response.length; i &lt; l; i++) { s += '&lt;option value="' + response[i]["Id"] + '"&gt;' + response[i]["Descrizione"] + '&lt;/option&gt;'; } } return s + "&lt;/select&gt;"; } }, editrules: { required: true } }, { name: 'CreatedBy', index: 'CreatedBy', align: "center", search: false, sorttype: 'text', width: 40, searchoptions: { sopt: ['eq', 'ne', 'cn'] }, editable: false, editoptions: { readonly: true} }, { name: 'CreationDate', index: 'CreationDate', align: "center", search: false, sorttype: 'text', width: 30, searchoptions: { sopt: ['eq', 'ne', 'cn'] }, editable: false, editoptions: { readonly: true} }, { name: 'Status', index: 'Status', width: 50, hidden: true, edittype: 'select', editable: true, editrules: { edithidden: true, required: true }, editoptions: { dataUrl: '&lt;%# ResolveUrl("~/path/to/myCSharpWebService") %&gt;', buildSelect: function (data) { var retValue = $.parseJSON(data); var response = $.parseJSON(retValue.d); var s = '&lt;select id="myid3" name="myid3"&gt;'; if (response &amp;&amp; response.length) { for (var i = 0, l = response.length; i &lt; l; i++) { s += '&lt;option value="' + response[i]["Id"] + '"&gt;' + response[i]["Descrizione"] + '&lt;/option&gt;'; } } return s + "&lt;/select&gt;"; } } }, { name: 'Features', index: 'Features', width: 50, hidden: true, edittype: 'select', editable: true, editrules: { edithidden: true, required: true }, editoptions: { dataUrl: '&lt;%# ResolveUrl("~/path/to/myCSharpWebService") %&gt;', buildSelect: function (data) { var retValue = $.parseJSON(data); var response = $.parseJSON(retValue.d); var s = '&lt;select id="myid4" name="myid4"&gt;'; if (response &amp;&amp; response.length) { for (var i = 0, l = response.length; i &lt; l; i++) { s += '&lt;option value="' + response[i]["Id"] + '"&gt;' + response[i]["Descrizione"] + '&lt;/option&gt;'; } } return s + "&lt;/select&gt;"; } } } ], </code></pre> <p>this is an extract of the function I use to create a grid on my aspx page. There are 10cols, as you can see from colModel, but just 7 of them are shown by jqGrid; I need the others 'cause I want to show them up in modal popup form when I edit a record on the grid. </p> <p>Now, I'd like to write down cleaner code: I'd prefer to add these 3 more fields on edit button click when popup is built, instead of listing them in colModel</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload