Note that there are some explanatory texts on larger screens.

plurals
  1. POJQGrid Edit mode: how to populate a select list based on selection in a different select list
    primarykey
    data
    text
    <p>I have a jqGrid that when I go into edit mode I need to have 2 select lists. I need the second list to filter based on the selection from select list 1.</p> <p>This is my first attempt at working with jqGrid so I am having some troubles with things.</p> <p>I have seen a few examples that are using hard coded arrays etc., but I need to pull the information from a database and I am having trouble getting it to work.</p> <p>I guess I need to have my hand held through this one. :-p</p> <p>My columns in question are the AssemblyTypeName and the AssemblyName, I need to fill them in that order.</p> <p>My jqGrid code is below:</p> <pre><code> $("#jqTable").jqGrid({ // Ajax related configurations url: '@Url.Action("_CustomBinding")', datatype: "json", mtype: "POST", postData: { programID: function () { return $("#ProgramID option:selected").val(); }, buildID: function () { return $('#Builds option:selected').val(); } }, // Specify the column names colNames: ["Actions", "Assembly ID", "Assembly Type", "Assembly Name", "Cost", "Order", "Budget Report", "Partner Request", "Display"], // Configure the columns colModel: [ { name: 'myac', width: 80, fixed: true, sortable: false, resize: false, formatter: 'actions', formatoptions: { keys: true} }, { name: "AssemblyID", key: true, index: "AssemblyID", width: 40, align: "left", editable: false }, { name: "AssemblyTypeName", index: "AssemblyTypeName", width: 100, align: "left", editable: true, edittype: 'select', editoptions: { dataUrl: '@Url.Action("_AssemblyTypes")', buildSelect: function (data) { var response = jQuery.parseJSON(data); var s = '&lt;select&gt;'; if (response &amp;&amp; response.length) { for (var i = 0, l = response.length; i &lt; l; i++) { var ri = response[i]; s += '&lt;option value="' + ri + '"&gt;' + ri + '&lt;/option&gt;'; } } return s + "&lt;/select&gt;"; } } }, { name: "AssemblyName", index: "AssemblyName", width: 100, align: "left", editable: true, edittype: 'select', editoptions: { dataUrl: '@Url.Action("_Assemblies")', buildSelect: function (data) { var response = jQuery.parseJSON(data); var s = '&lt;select&gt;'; if (response &amp;&amp; response.length) { for (var i = 0, l = response.length; i &lt; l; i++) { var ri = response[i]; s += '&lt;option value="' + ri + '"&gt;' + ri + '&lt;/option&gt;'; } } return s + "&lt;/select&gt;"; } } }, { name: "AssemblyCost", index: "AssemblyCost", width: 50, align: "left", formatter: "currency", editable: true }, { name: "AssemblyOrder", index: "AssemblyOrder", width: 50, align: "left", editable: true }, { name: "AddToBudgetReport", index: "AddToBudgetReport", width: 100, align: "center", formatter: "checkbox", editable: true, edittype: 'checkbox' }, { name: "AddToPartnerRequest", index: "AddToPartnerRequest", width: 100, align: "center", formatter: "checkbox", editable: true, edittype: 'checkbox' }, { name: "Show", index: "Show", width: 50, align: "center", formatter: "checkbox", editable: true, edittype: 'checkbox'}], // Grid total width and height and formatting //width: 650, //height: 220, altrows: true, // Paging //toppager: true, pager: $("#jqTablePager"), rowNum: 10, rowList: [10, 20, 30], viewrecords: true, // Specify if "total number of records" is displayed emptyrecords: 'No records to display', // Default sorting sortname: "AssemblyID", sortorder: "asc", // Grid caption caption: "Build Template", // grid command functionality editurl: '@Url.Action("_AjaxUpdate")', onSelectRow: function (AssemblyID) { if (AssemblyID &amp;&amp; AssemblyID !== lastsel) { $('#jqTable').jqGrid('restoreRow', lastsel); var cm = $("#jqTable").jqGrid('getColProp', 'AssemblyTypeName'); cm.editable = false; $("#jqTable").jqGrid('editRow', AssemblyID, true); cm.editable = true; lastsel = AssemblyID; } } }).navGrid("#jqTablePager", { refresh: false, add: true, edit: false, del: false }, {}, // settings for edit {}, // settings for add {}, // settings for delete {sopt: ["cn"]} // Search options. Some options can be set on column level ); </code></pre> <p>Thanks for the help and patience.</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.
    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