I am having a devil of a time populating a drop down list in a sub-grid. I am using free-jqgrid 4.15.5. I have no issues when populating a drop down in the main grid but it appears that I am having ID issues when trying to get a simular drop down in the subgrid ( grid as a subgrid option) dows anyone know a reference or how to populate the drop down correctly?
my current test function for the drop down is:
function popUsersT() {
alert("subgrid id : " + window.subgrid_id + "\nfound : " + $("#" + subgrid_id).length + "\nrow id : " + window.row_id + "\nfound(row) : " + $("#" + window.row_id).length + "\ndropdown found : " + $("select", "#" + window.row_id).length + "\nsg_tableID: " + $("#" + sg_tableID).html);
var current = $("#" + subgrid_id).jqGrid('getRowData', $("#" + window.subgrid_table_id )[0].p.selrow).TaskValidator;
alert(current);
$.ajax({
url: "/Tasks/getUserList",
datatype: 'json',
mtype: 'Get',
async: false,
success: function (users) {
$("#Task").html("");
$("#Proxy").html("");
$.each(users, function (i, user) {
$("#Task").append(
$('<option></option>').val(user.name).html(user.DisplayName)
);
$("#Proxy").append(
$('<option></option>').val(user.name).html(user.DisplayName)
);
});
$("#Task").prop("disabled", false);
$("#Proxy").prop("disabled", false);
$("#Task").val(current);
$("#Proxy").val(current);
}
});
}
part of my subgrid is:
subGridRowExpanded: function (subgrid_id, row_id) {
var sg_tableID = subgrid_id + "_t";
window.subgrid_id = sg_tableID;
window.row_id = row_id;
window.subgrid_table_id = sg_tableID;
//alert(subgrid_id);
//alert(row_id);
var pager_id = "p_" + sg_tableID;
$("#" + subgrid_id).html("<table id='" + sg_tableID + "' class='scroll'></table><div id='" + pager_id + "' class='scroll'></div>");
jQuery("#" + sg_tableID).jqGrid({
url: "/Home/GetTaskSubList/" + row_id,
I keep playing with the Id values to try to get away from the errors of: Error: 'subgrid_table_id' is undefined Error: 'sg_tableID' is undefined
I am sure i am getting lost in trying to make this work, and was hoping this was something easy i am over looking.
thank you for your help
in the end iw as able to get it workign by setting the values:
subGridRowExpanded: function (subgrid_id, row_id) {
var sg_tableID = subgrid_id + "_t";
window.subgrid_id = sg_tableID;
window.row_id = row_id;
window.subgrid_table_id = sg_tableID;
and then referencing the values in the function by:
var currentOwner = $("#" + subgrid_id).jqGrid('getRowData', $("#" + window.subgrid_table_id)[0].p.selrow).Task;
I am not sure i fully understand the why but it does seem to work as needed. thank you