在網格內部,在'批准/拒絕'列OnRowCommand中有一個ID爲'txtRemarksByEntity'的文本框,我需要檢索文本框的值。如何獲取文本輸入字段的值?
function BtnProcurementApprovalByEntityClick(rowId, value) {
var rowData = $('#GridProcureApprovalByEntity').getRowData(rowId);
ReqIdApproval = rowData['RequestId'];
ApprovalEntityId = rowData['approvalentityid'];
ApprovalTypeId = rowData['approvaltypeid'];
ApprovalStatusText = rowData['status_desc'];
var ab = rowData["Approve/Reject"];
var $str1 = $(ab);
alert($str1.val());
}
在rowData變量,我得到
Approval_Type:"Oprations"
Approve/Reject:"Remarks <input type="text" id="txtRemarksByEntity" class="txtRemarksByEntity" style="width: 250px"> <img src="images/yes1.PNG" style="cursor:pointer;" onclick="BtnProcurementApprovalByEntityClick(5 , 1)"> <img src="images/cross1.PNG" style="cursor:pointer;" onclick="BtnProcurementApprovalByEntityClick(5 , 2)">"
RequestId:"51213"
Request_Id:"PR51213"
SrNo:"5"
approvalentityid:"2234"
approvaltypeid:"2"
status_desc:"<span style="color:#EAA66A"><b>Pending</b></span>"
statusid:"0"
undefined:"<button type="button" class="button edit" onclick="editProcureApprovalByEntity(5)">Edit</button>"
我動態結合電網如下
$("#GridProcureApprovalByEntity").jqGrid({
autowidth: true,
height: 'auto',
shrinkToFit: true,
data: arr,
datatype: "local",
colNames: ['SrNo', 'PR No.', 'Approval Type', 'Approval Status', 'statusid', 'approvaltypeid', 'Approve/Reject', '', 'approvalentityid', 'RequestId'],
colModel: [{
name: 'SrNo',
index: 'SrNo',
width: 30,
align: 'center'
}, {
name: 'Request_Id',
index: 'Request_Id',
width: 50,
align: 'center'
},
{
name: 'Approval_Type',
index: 'Approval_Type',
width: 100,
align: 'center'
}, {
name: 'status_desc',
index: 'Approval Status',
width: 80,
align: 'center',
formatter: ApprovalFormatter
}, {
name: 'statusid',
index: 'statusid',
width: 0,
hidden: true
}, {
name: 'approvaltypeid',
index: 'approvaltypeid',
width: 0,
hidden: true
},
//{
// align:'center',
// formatter: function (cellvalue, options, rowobject) {
// return '<button type="button" class="button edit" onClick="editProcureApproval(' + options.rowId + ')">Edit</button>';
// }
// },
{
name: 'Approve/Reject',
index: 'Approve/Reject',
formatter: formateeApprovalByEntity, width: 250,
align: 'center'
},
{
formatter: formateApprovalByEntity, width: 50
},
{
name: 'approvalentityid',
index: 'approvalentityid',
width: 0,
hidden: true
},
{
name: 'RequestId',
index: 'RequestId',
width: 0,
hidden: true
}
],
pager: "#PagingGridProcureApprovalByEntity",
rowNum: 10,
//rowList: [1, 2, 3],
//sortname: "Sno",
//sortorder: "desc",
viewrecords: true,
gridview: true,
autoencode: true,
hoverrows: false,
gridComplete: function() {
var recs = $("#GridProcureApprovalByEntity").getGridParam("reccount"); // parseInt($("#GridApproval").getGridParam("records"));
if (isNaN(recs) || recs == 0) {
$("#dvProcureAppGridByEntity").hide();
}
},
ondblClickRow: function (rowId) {
},
loadComplete: function() {
$("tr.jqgrow:odd").css("background", "#EEF7FB");
}
//, caption: "Approval Details"
}).jqGrid("navGrid", "#PagingGridProcureApprovalByEntity", {
search: false,
edit: false,
add: false,
del: false,
refreshstate: "current"
});
function formateeApprovalByEntity(cellvalue, options, rowobject) {
var str = '';
if (rowobject.statusid == "0") {
str = 'Remarks <input type="text" id="txtRemarksByEntity" class="txtRemarksByEntity" style= "width: 250px"/>' + ' ' +
'<img src="images/yes1.PNG" style="cursor:pointer;" onClick="BtnProcurementApprovalByEntityClick(' + options.rowId + ' , ' + 1 + ')"/>' + ' ' +
'<img src="images/cross1.PNG" style="cursor:pointer;" onClick="BtnProcurementApprovalByEntityClick(' + options.rowId + ' , ' + 2 + ')"/>'
}
else {
str = '';
}
return str;
}
$ str1.val()始終是 「」
ID是唯一的,我得到的所有列值都與RowID相關,但txtRemarksByEntity值始終爲空。 – Soniya