这是一个小例子:
var distinctValues = [];
distinctValues.push("Value1");
distinctValues.push("Value2");
var firstValue = distinctValues[0];
var searchResults = [];
var data = grid.jqGrid('getGridParam', 'data');
data.forEach(function (row) {
searchResults[searchResults.length] =
{
"ID" : row.ID,
"CreatedBy": row.CreatedBy,
"UpdatedBy": row.UpdatedBy
}
}
如何在 searchResults 数组中查看 firstValue("Value1") 并检索 CreatedBy 信息?
//something like this - this is wrong syntax by the way
if ($.inArray(firstValue, searchResults) != -1) {
alert(searchResults["CreatedBy"]);
}