Dear all,
I was trying lot to get a update textbox template value from jqgrid, but the problem is when ever i used a beforeSelectRow event first time i am getting null secind time i am getting value (I know because , at the first time) it doesn’t hold a value.
I am tried to use text change event but no use here is my code below.
Please help.
function getReadListData(jsondata) {
$(“#jqGrid”).jqGrid({
datatype: ‘local’,
data: jsondata,
mtype: ‘GET’,
height: 300,
width: 1275,
gridview: true, shrinkToFit: false,
viewrecords: true,
autoencode: true,
colModel: [
{ label: ‘ID’, name: ‘BorroweridPK’, width: 100, frozen: true, align: ‘center’ },
{
name: ‘ReadListAssigned’, name: ‘ReadListAssigned’, width: 180, edittype: ‘select’, align: ‘center’, editable: true, frozen: true,
formatter: function (cellValue, option) {
return getuserdetails(cellValue, option);
}
},
{ label: ‘Read List’, name: ‘ReadListFlag’, width: 110, frozen: true, align: ‘center’, formatter: ‘checkbox’ ,formatoptions: { disabled: false }},
{ label: ‘FRB’, name: ‘IsFRB’, width: 100, frozen: true, align: ‘center’, formatter: ‘checkbox’, formatoptions: { disabled: false } },
{
label: ‘Comments’, name: ‘Remarks’, width: 300, frozen: true, align: ‘center’, editable: true,formatter: function (cellValue, option) {
return ‘<input type=”text” size=”40″ style=”height:40px” name=”txtBox” id=”txt_’ + option.rowId +
‘” value=”‘ + cellValue + ‘ ” onchange=”‘ + jsFunction ()+ ‘”/>’;
}
},
{ label: ‘Borrower Name’, name: ‘BorrowerName’, width: 400, frozen: true, align: ‘center’ },
{ label: ‘Internal’, name: ‘BorrowerInternal’, width: 100, align: ‘center’ },
{ label: ‘CEA’, name: ‘BorrowerCEA’, width: 100, align: ‘center’ },
{ label: ‘Citizenship’, name: ‘CitizenShipCode’, width: 110, align: ‘center’ },
{ label: ‘Credit’, name: ‘TotalExp’, width: 100, align: ‘right’ },
{ label: ‘Commit’, name: ‘Commitments’, width: 100, align: ‘right’,formatter:currencyFmatter },
{ label: ‘Loans’, name: ‘Loans’, width: 100, align: ‘right’ },
{ label: ‘Lcs’, name: ‘Lcs’, width: 100, align: ‘right’ },
{ label: ‘TF’, name: ‘TradeFinance’, width: 100, align: ‘right’ },
{ label: ‘Market’, name: ‘TotalMktExp’, width: 100, align: ‘right’ },
{ label: ‘Derv’, name: ‘Derivatives’, width: 100, align: ‘right’ },
{ label: ‘FX’, name: ‘FX’, width: 100, align: ‘right’ },
{ label: ‘MM’, name: ‘MoneyMarket’, width: 100, align: ‘right’ },
{ label: ‘Sec’, name: ‘Securities’, width: 100, align: ‘right’ },
],
loadComplete: function () {
var vv = “dfgdfgdF”;
// now you can manipulate rowData as it has all of the DOM elements of that row.
},
beforeSelectRow: function (rowid, e) {
var $self = $(this),
iCol = $.jgrid.getCellIndex($(e.target).closest(“td”)[0]),
cm = $self.jqGrid(“getGridParam”, “colModel”),
localData = $self.jqGrid(“getLocalRow”, rowid);
if (cm[iCol].name == “ReadListFlag”) {
localData.ReadListFlag = $(e.target).is(“:checked”);
// alert(‘hello’);
}
if (cm[iCol].name == “Remarks”) {
// alert(‘hell3’);
//localData.Remarks = “sdfsdfsd”;
var $txt = $(e.target).closest(‘tr’).find(‘input[type=”text”]’);
//alert($txt.val());
// alert($txt.attr(‘value’));
//$(“#jqGrid”).jqGrid(“setCell”, rowid, “Remarks”, “New value”);
}
if (cm[iCol].name == “ReadListAssigned”) {
}
return true; // allow selection
}
});
$(“#jqGrid”).jqGrid(‘setFrozenColumns’);
$(“#jqGrid”).saveRow (1, false, ‘clientArray’);
}
function currencyFmatter (cellvalue, options, rowObject)
{
return “$”+cellvalue;
}
function jsFunction()
{
//$(“#jqGrid”).jqGrid(“setCell”, rowid, “Remarks”, “New value”);
alert(‘sdfsdfsdf’);
}
function getuserdetails(cellValue, option)
{
var s = ‘<select id=’ + option.rowId + ‘>’;
s += ‘<option value=”‘ +-1 + ‘”> Please select user</option>’;
$.ajax({
type: “POST”,
async: false,
data: “{}”,
url: “../AQReviewPages/LineCard.aspx/GetAllUsers”,
contentType: “application/json; charset=utf-8”,
dataType: “json”,
success: function (Result) {
users = Result.d;
$.each(users, function (key, value) {
// $(“#ddl” + rowid).append($(“<option></option>”).val(value.UserPK).html(value.FirstName));
if (cellValue == value.UserPK)
s += ‘<option value=”‘ + value.UserPK + ‘” selected>’ + value.FirstName + ‘</option>’;
else
s += ‘<option value=”‘ + value.UserPK + ‘”>’ + value.FirstName + ” “+ value.LastName+ ‘</option>’;
});
},
error: function (Result) {
alert(“Error”);
}
});
return s + “</select>”;
}
});
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top