jqGrid gridComplete:- getRowData - get row cell value from array(jqGrid gridComplete:- getRowData - 从数组中获取行单元格值)
问题描述
请 - 需要从 jqGrid getRowData 设置变量的语法属性
Please - need syntax for setting variables from jqGrid getRowData property
循环遍历行 - 只需将 ID 和 Phrase 列值拉入变量
Looping thru rows - just need to pull the ID and Phrase column values into variables
gridComplete: function () {
var allRowsInGrid = $('#list').jqGrid('getRowData');
for (i = 0; i < allRowsInGrid.length; i++) {
pid = allRowsInGrid[i].ID;
vPhrase = allRowsInGrid[i].Phrase;
vHref = "<a href='#' onclick='openForm(" + pid + ", " + vPhrase + ")'>View</a>";
}
},
能够使用 getDataIDs 轻松获取 ID :-)
Was able to get ID easy enough with getDataIDs :-)
在获取 i 的 pid 和 vPhrase 的特定列值方面需要帮助
Need help with getting specific column values for pid and vPhrase for i
干杯
推荐答案
试试这个:
var ids = jQuery("#list").jqGrid('getDataIDs');
for (var i = 0; i < ids.length; i++)
{
var rowId = ids[i];
var rowData = jQuery('#list').jqGrid ('getRowData', rowId);
console.log(rowData.Phrase);
console.log(rowId);
}
请注意:如果您的目标是添加一个指向调用 javascript 方法的单元格的链接,您可以使用如下所示的 formatter 来实现此目的,应该像添加其他列一样将格式化程序添加到 colModel名称,索引,宽度,对齐等属性,因此您可以避免对行数据的迭代
Please Note: If your goal is to add a link to cell which calls a javascript method you can achieve this by using formatter like given below, formatter should be added to colModel like you add other column properties like name,index,width,align etc, so you can avoid the iteration over row data
formatter: function(cellvalue, options, rowObject) {
return "<a href='#' onclick='openForm("
+ rowObject.ID + ", "
+ rowObject.Phrase
+ ")'>View</a>";
}
这篇关于jqGrid gridComplete:- getRowData - 从数组中获取行单元格值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:jqGrid gridComplete:- getRowData - 从数组中获取行单元格值
基础教程推荐
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
