单击时获取行的 ID
get id of the row on click
>伙计们,我正在使用jqgrid...我想在单击图像时仅获取行的ID,而无需先选择整行..这是我的代码
<script type="text/javascript">
$(document).ready(function() {
$("#jqGrid").jqGrid({
url: 'data.json',
datatype: "json",
styleUI: "Bootstrap",
colModel: [{
label: 'Order ID',
name: 'OrderID',
key: true,
width: 75,
hidden: true
}, {
label: 'From Date',
name: 'FromDate',
width: 150,
editable: true,
edittype: "text",
id: "ui-datepicker-div",
editoptions: {
dataInit: function(element) {
$(element).datepicker({
autoclose: true,
format: 'yyyy-mm-dd',
orientation: 'auto bottom'
});
},
},
}, {
label: 'To Date',
name: 'ToDate',
width: 150,
editable: true,
edittype: "text",
editoptions: {
dataInit: function(element) {
$(element).datepicker({
autoclose: true,
format: 'yyyy-mm-dd',
orientation: 'auto bottom'
});
},
},
}, {
label: 'Customer ID',
name: 'CustomerID',
width: 150
}, {
label: 'Ship Name',
name: 'ShipName',
width: 200
}, {
label: 'Row Data',
name: 'RowData',
align: 'center',
formatter: function() {
return "<img src='resources/icon.jpg' onclick='OpenDialog()' alt='Data Row' />";
width = 15;
}
}, ],
loadonce: true,
......
});
});
...........
function OpenDialog() {
var result = "";
var grid = $("#jqGrid");
var rowKey = grid.getGridParam("selrow");
rowData = grid.getLocalRow(rowKey);
for (var item in rowData) {
if (item == 'RowData') {
break;
}
result += rowData[item] + ', ';
}
alert(result);
}
请提供任何帮助 如何在仅单击图像时获取行的 ID ??..非常感谢.. 提前感谢
请使用以下 html:
onclick='OpenDialog(this)'
在 OpenDialog 中使用最接近的 jquery 方法:
function OpenDialog(element) {
var id = $(element).closest('tr').attr('id');
...
}
相关文章:
- 使用angularjs中的rest调用通过id获取数据
- javascript从id获取数字
- 如何通过ID获取图层对象
- 通过jstree中的Id获取节点
- 在控制器中按ID获取XML ViewElement(MultiInput)
- node.js使用monk从数组中按id获取文档
- 如何使用API从多个IMDB ID获取电影信息
- 我的ID获取元素不起作用
- 如何通过 id 获取“this”元素并查看是否选中
- 使用类而不是 ID(通过 CLASS 而不是 ID 获取元素)
- 如何在Ember.js中使用jQuery通过id获取元素
- 使用类名按ID获取元素
- jquery模态对话框通过id获取输入类型text的值
- 通过ID获取声明性dojo数据网格
- 可以't按id获取元素
- 根据DropDown ID获取DropDownListFor的选定值
- jquery如何使用chlid id获取父元素的类
- 在iframe中通过id获取元素
- 主干模型通过ID获取JSON元素
- 在javascript中通过id获取元素,而页面上没有任何表单标记