にjsonData
バインドするために使用していますが、フィールドでjqgrid
も使用したいと考えてmodel.total amount
います。
jsonData
では、 this 内で使用するにはどうすれば返すことができ<td>
ますか?
意見
<table>
<tr>
<td>@Model.TotalAmount</td>
</tr>
</table>
コントローラ
public ActionResult GetDocPendingDetails(string strPA, string strEmpCode, string StrModeOfPayment) // Sends PA to bind the gridview
{
string StrEmpcode = ""; // to be changed
cmn_top objCmn_top = new cmn_top();
DataTable dtData = new DataTable();
Items objitem = new Items();
if (StrModeOfPayment == "All")
{
StrModeOfPayment = "";
}
dtData = objCmn_top.Reports_GetData__DocPendingPayment(strPA, StrEmpcode, StrModeOfPayment);
ViewBag.TotalAmount = dtData.AsEnumerable().Sum(x => x.Field<double>("fl_approvedamt")).ToString(); // to be changed later
int totalRecords = dtData.Rows.Count;
var jsonData = new
{
totalamount = ViewBag.TotalAmount,
total = totalRecords,
rows =
(
from dtRow in dtData.AsEnumerable()
select new
{
cell = new string[]
{
dtRow.Field<string>("ch_docno"),dtRow.Field<string>("ch_empcode"),dtRow.Field<string>("ch_sapvoucherno"), dtRow.Field<string>("CH_PSA_CODE"),dtRow.Field<double>("fl_approvedamt").ToString()
}
}
)
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
これは私のjqgridです
$("#list").GridUnload();
$("#list").jqGrid({
url: '/Reports/GetDocPendingDetails',
datatype: 'json',
mtype: 'GET',
colNames: ['Document No.', 'Document Owner', 'SAP Document No', 'PSA', 'Approved Amount'],
colModel: [
{ name: 'ch_docno', index: 'ch_docno', width: 100, align: 'center' },
{ name: 'ch_empcode', index: 'ch_empcode', width: 250, align: 'left' },
{ name: 'ch_sapvoucherno', index: 'ch_sapvoucherno', width: 100, align: 'center' },
{ name: 'CH_PSA_CODE', index: 'CH_PSA_CODE', width: 200, align: 'left' },
{ name: 'fl_approvedamt', index: 'fl_approvedamt', width: 100, align: 'center' }
],
emptyrecords: "Empty records",
height: 'auto',
loadtext: 'Loading.....',
sortorder: 'asc',
caption: " Documents Pending For Payment ",
shrinkToFit: true,
rownumbers: true,
rowNum: -1,
postData: { strPA: selectedPA, StrModeOfPayment: modeOfPayment },
viewrecords: true,
gridComplete: function () {
var recs = parseInt($("#list").getGridParam("records"));
if (isNaN(recs) || recs == 0) {
$("#gridWrapper").hide();
$("#DivEmptyRecords").show();
}
else {
$('#gridWrapper').show();
$("#DivEmptyRecords").hide();
}
}
});
//document.getElementById("tdTotalAmount").innerHTML = jsonData.TotalAmount;
}