gpt4 book ai didi

jquery - jqGrid - 从父网格获取未格式化的 rowData

转载 作者:行者123 更新时间:2023-12-01 01:22:45 26 4
gpt4 key购买 nike

我有以下 jqGrid 和使用 subgrid 的子网格。在 subGridRowExpanded 事件中,我尝试提醒父行的列值,如下所示 - 但它仅显示格式化值。

从 showChildGrids 函数内选定的父行获取列值的最佳 jqGrid 方法是什么?

    function showChildGrids(parentRowID, parentRowKey) 
{
alert(parentRowKey);
var rowData = $(mainGrid).jqGrid('getRowData', parentRowKey)
//var rowData = $(mainGrid).getRowData(parentRowID);

alert(rowData.RoutingID);
}

function createRoutingGrid()
{

$(mainGrid).jqGrid({
url: "invNewWORouting.aspx/GetRoutings",
mtype: 'POST',
datatype: "local", //json if want to load initially
ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
postData:
{
workOrder: function ()
{
//var selectedWorkOrder = $( "select[class='workOrderDropdown']" ).val();
//return selectedWorkOrder;
return "5454430506";
}
},

serializeGridData: jqGridCustomSerializer,
jsonReader: {
repeatitems: false,
root: function (obj) { return obj.d; }
},
colNames: ['Routing ID', 'Destinations'],
colModel: [
{ name: 'RoutingID', index: 'RoutingID', formatter:mySpacePreserveFormatter, width:150 },
{ name: 'Destinations', index: 'Destinations', width:400 }
],
multiselect:true,
multiboxonly:false,
rowNum: 10,
viewrecords: true,
gridview: true,
height: "auto",
loadonce: true,
subGrid: true, // set the subGrid property to true to show expand buttons for each row
subGridRowExpanded: showChildGrids, // javascript function that will take care of showing the child grid
subGridOptions: { "plusicon" : "ui-icon-plus",
"minusicon" :"ui-icon-minus",
"openicon" : "",
"reloadOnExpand" : false,
"selectOnExpand" : false },
beforeSelectRow: function (rowid, e)
{
//Reset all checkboxes before selection
$(this).jqGrid('resetSelection');

var $self = $(this);
var $td = $(e.target).closest("tr.jqgrow>td");
var rowid = $td.parent().attr("id");
var rowData = $self.jqGrid("getLocalRow", rowid);

//Set variable for RoutingID
userSelectedRoutingID = rowData.RoutingID;

//Allow row selection
return true;
}
});

//Hide header checkbox
$("#cb_"+mainGrid[0].id).hide();
}

格式化程序

        function mySpacePreserveFormatter (cellvalue, options, rowObject)
{
return '<pre>' + cellvalue + '</pre>';
}

输出

enter image description here

最佳答案

您可以在 colModel 中添加一个包含非格式化路由 ID 的隐藏列:

  colNames: ['Routing ID', 'Destinations', 'nonFormattedRoutingID'],
colModel: [
{ name: 'RoutingID', index: 'RoutingID', formatter:mySpacePreserveFormatter, width:150 },
{ name: 'Destinations', index: 'Destinations', width:400 },
{name: 'nonFormattedRoutingID', index: 'nonFormattedRoutingID', hidden:true}
],

然后在函数showChildGrids中获取该列的值

关于jquery - jqGrid - 从父网格获取未格式化的 rowData,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31835963/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com