我需要从网格“FarmacoGrid”中提取数据“FechaCaducidad”,以将其存储在辅助变量“fechaCadAux”中。我尝试过几种不同的方式,但没有成功。
$(document).ready(function () {
$("#FarmacoGrid").jqGrid({
url: '@Url.Action("Load", "Farmaco")',
datatype: 'json',
mtype: 'POST',
autowidth: true,
altRows: true,
altclass: 'grid-alt-row',
rowNum: @(ViewBag.PageSize * (ViewBag.PageIndex + 1)),
colNames: ['NomFarmaco', 'Cantidad', 'FechaCaducidad', 'FechaPedido','FechaReposicion', '', '', '', ''],
colModel: [
{ index: 'NomFarmaco', name: 'NomFarmaco', sortable: true, resizable: false },
{ index: 'Cantidad', name: 'Cantidad', sortable: true, resizable: false },
{ index: 'FechaCaducidad', name: 'FechaCaducidad', sortable: true, resizable: false },
{ index: 'FechaPedido', name: 'FechaPedido', sortable: true, resizable: false },
{ index: 'FechaReposicion', name: 'FechaReposicion', sortable: true, resizable: false },
{ name: 'imagen', sortable: false, classes: 'grid-cell-imagen', resizable: false },
{ name: 'fechaCadAux', sortable: false, classes: 'grid-cell-fechaCadAux', resizable: false },
{ name: 'fechaHoyAux', sortable: false, classes: 'grid-cell-fechaHoyAux', resizable: false },
{ name: 'edit', sortable: false, classes: 'grid-cell-edit', resizable: false },
],
gridComplete:
function(){
var ids = jQuery("#FarmacoGrid").jqGrid('getDataIDs');
for(var i=0;i < ids.length;i++)
{
var rowId = ids[i];
var fechaCadAux = $("#FarmacoGrid"+FechaCaducidad).val();
var fechaHoyAux = Date.parse(new Date());
var imagenHtml = imagenHtml = '<img src="@Url.Content("~/Content/Images/verde.png")"/>';
var editHtml = '<a href="@Url.Action("Edit", "Farmaco")/' + rowId + '" title="@Resources.Shared.Edit"><img src="@Url.Content("~/Content/Images/CRUD/edit.png")"/></a>';
var deleteHtml = '<a href="#" onclick="return DeleteGridItem(\'FarmacoGrid\', \'@Url.Action("Delete", "Farmaco")\', \'' + rowId + '\')" title="@Resources.Shared.Delete"><img src="@Url.Content("~/Content/Images/CRUD/delete.png")"/></a>';
$("#FarmacoGrid").jqGrid('setRowData', ids[i], { imagen: imagenHtml, "fechaCadAux": fechaCadAux, "fechaHoyAux": fechaHoyAux, "edit": editHtml, "delete": deleteHtml});
}
答案 0 :(得分:0)
我自己的问题的解决方案是:
var fechaCadAux = jQuery("#FarmacoGrid").jqGrid('getRowData',rowId).FechaCaducidad;