Я использую jqgrid во всем приложении. На двух экранах со встроенным редактированием все отлично работает. Если поле имеет значение, оно помещает это значение в текстовое поле при переходе в режим редактирования.
На одной сетке этого не происходит, и все поля становятся пустыми, когда активирован режим редактирования.
Кто-нибудь знает, почему это может происходить?
кода немного много, поэтому я буду публиковать сообщения только по запросу. Пока у кого-нибудь есть мысли о том, почему это происходит? Спасибо!
РЕДАКТИРОВАТЬ - Код:
Сначала вызываются значения по умолчанию, затем Init внизу запускает остальные. Дайте мне знать, если потребуется больше.
Вот мой вызов setDefaults:
$.extend($.jgrid.defaults, {
datatype: 'json',
height: "100%",
loadui: 'none',
images: "/css/redmond/images/",
jsonReader: {
root: "Rows",
page: "Page",
total: "Total",
records: "Records",
repeatitems: false,
userdata: "UserData",
id: "Id"
},
mtype: 'GET',
autowidth: true,
rowNum: 10,
rowList: [10, 20, 50, 100],
viewrecords: true,
loadError: function (xhr, status, error) {
alert('todo: implement error method - ' + error);
},
beforeRequest: function () {
$("#load_grid").html('<h4 style="display: inline; position: relative; top: -10px; font-weight: bold">Loading...</h4>' + $(".loader").html());
Common.Helpers.DisableControls();
if (multi !== undefined && !multi)
$("#grid").setGridParam({ multiselect: true }).showCol('cb');
},
gridComplete: function () {
if (!loadonce) {
multi = false;
Common.Grid.LoadNavBar();
Common.Grid.InitFilters();
$("th[id=grid_cb]")
.css("text-align", "center")
.css("position", "relative")
.css("left", "1px");
}
Common.Helpers.EnableControls();
}
});
Вот весь код, указанный на соответствующей странице:
DoubleClickRow: function (id) {
if ($("#" + id).find("img[alt=loading]").length > 0)
alert('Please wait until row is fully loaded before editing.');
else {
var grid = $("#grid");
if (id && id !== lastsel) {
grid.saveRow(lastsel, true);
$("#grid").setSelection(id);
lastsel = id;
grid.editRow(id, true,
function (row) {
$("#" + row + "_StoreQty").select();
},
null,
null,
null,
{ "DetailId": $("#grid").getCell(id, "DetailId") },
function (row) { // on success
var rowId = row;
var row = $("#" + rowId);
var grid = $("#grid");
grid.setSelection(row.next().attr("id"));
row.next().focus();
Store.Cuts.Index.DoubleClickRow(row.next().attr("id"));
},
null,
null
);
}
}
},
setupGrid: function (grid, pager) {
Common.Grid.GetColumnModel();
grid.jqGrid({
colNames: colNames,
colModel: colModel,
pager: pager,
editurl: editurl,
url: gridurl,
pager: pager,
height: 250,
rowNum: 20,
ondblClickRow: Store.Cuts.Index.DoubleClickRow,
onSelectRow: function (id) {
if (id && id !== lastsel) {
grid.saveRow(lastsel, true);
}
},
loadComplete: function () {
if (!loadonce) {
loadonce = true;
var ddlVendors = $(".ddl-vendors");
$(vendors).each(function () {
ddlVendors.append('<option value="' + this.Vendor + '">' + this.Vendor + '-' + this.VendorName + '</option>');
});
$(".footer-row").show();
}
if (grid.getGridParam("reccount") === 0) {
$("#empty-grid-message").show();
} else {
$("#empty-grid-message").hide();
}
grid
.setLabel('VendorItem', '', 'right')
.setLabel('UPC_DISPLAY', '', 'right')
.setLabel('CasePack', '', 'right')
.setLabel('Retail', '', 'right')
.setLabel('Express', '', 'right')
.setLabel('InvQty', '', 'right')
.setLabel('Qty', '', 'right')
.setLabel('StoreQty', '', 'right');
grid.resetSelection();
var rows = grid.getRowData();
$(rows).each(function () {
$.ajax(
{
url: pricingurl,
data: "di_id=" + this["ItemId"],
success: function (result) {
try {
$("." + result.Id + "_Retail").html("").html(result.Retail);
$("." + result.Id + "_Sale").html("").html(result.SaleAmt);
$("." + result.Id + "_Inventory").html("").html(result.InvQty);
}
catch (ex) {
$(".ajax").html(result);
}
}
});
});
}
});
},
Init: function () {
$.when(Store.Cuts.Index.GetPageData())
.then(function () {
Store.Cuts.Index.setupGrid($("#grid"), $("#pager"));
Common.Grid.InitGridEdit($("#grid"), Store.Cuts.Index.DoubleClickRow);
$(".ddl-vendors").change(function () {
extendedSearch.push({ name: "Vendor", value: $(".ddl-vendors").val() });
Common.Grid.FilterGrid();
});
$("#filter-div-btn-clear").click(function () {
$(".ddl-vendors").val("-1")
extendedSearch.push({ name: "Vendor", value: "-1" });
});
});
}
Вот моя Колмодель:
[{"Id":0,"display_order":0,"header":"ItemId","name":"ItemId","index":"ItemId","width":1,"align":"Left","search":false,"editable":false,"hidden":true,"editurl":"","edittype":"text","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""},
{"Id":0,"display_order":0,"header":"DetailId","name":"DetailId","index":"DetailId","width":1,"align":"Left","search":false,"editable":true,"hidden":true,"editurl":"","edittype":"text","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""},
{"Id":0,"display_order":0,"header":"Ship Date","name":"ShipDateDisplay","index":"ShipDateDisplay","width":75,"align":"Left","search":true,"editable":false,"hidden":false,"editurl":"","edittype":"text","editoptions":{"_value":" ","value":""},"surl":"","bytype":"twodates","bydescr":""},
{"Id":0,"display_order":0,"header":"Item","name":"VendorItem","index":"VendorItem","width":50,"align":"Right","search":true,"editable":false,"hidden":false,"editurl":"","edittype":"text","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""},
{"Id":0,"display_order":0,"header":"UPC","name":"UPC_DISPLAY","index":"UPC_DISPLAY","width":130,"align":"Right","search":true,"editable":false,"hidden":false,"editurl":"","edittype":"text","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""},
{"Id":0,"display_order":0,"header":"Description","name":"ItemDescription","index":"ItemDescription","width":200,"align":"Left","search":true,"editable":false,"hidden":false,"editurl":"","edittype":"text","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""},
{"Id":0,"display_order":0,"header":"Pack","name":"CasePack","index":"CasePack","width":35,"align":"Right","search":false,"editable":false,"hidden":false,"editurl":"","edittype":"text","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""},
{"Id":0,"display_order":0,"header":"Ret","name":"Retail","index":"Retail","width":50,"align":"Right","search":false,"editable":false,"hidden":false,"editurl":"","edittype":"","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""},
{"Id":0,"display_order":0,"header":"Exp","name":"Express","index":"Express","width":50,"align":"Right","search":false,"editable":false,"hidden":false,"editurl":"","edittype":"","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""},
{"Id":0,"display_order":0,"header":"Inv","name":"InvQty","index":"InvQty","width":30,"align":"Right","search":false,"editable":false,"hidden":false,"editurl":"","edittype":"","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""},
{"Id":0,"display_order":0,"header":"Memo","name":"Memo","index":"Memo","width":50,"align":"Left","search":false,"editable":false,"hidden":false,"editurl":"","edittype":"","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""},
{"Id":0,"display_order":0,"header":"Distro","name":"Qty","index":"Qty","width":50,"align":"Right","search":false,"editable":false,"hidden":false,"editurl":"","edittype":"","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""},
{"Id":0,"display_order":0,"header":"Request","name":"StoreQty","index":"StoreQty","width":60,"align":"Right","search":false,"editable":true,"hidden":false,"editurl":"","edittype":"text","editoptions":{"_value":" ","value":""},"surl":"","bytype":"text","bydescr":""},
{"Id":0,"display_order":0,"header":"Reason","name":"StoreReason","index":"StoreReason","width":160,"align":"Left","search":false,"editable":true,"hidden":false,"editurl":"","edittype":"select","editoptions":{"_value":"reasons ","value":"1:No Display/Running;0:Overstock"},"surl":"","bytype":"text","bydescr":""}]