<script type="text/javascript">
jQuery(document).ready(function () {
jQuery("#list").jqGrid({
url: '/agconhs/GetGridData',
datatype: 'json',
mtype: 'GET',
colNames: ['Conh. ID', 'Conhecimento', 'D.Lancamento', 'Destinatario', 'Local de Entrega', 'Fatura'],
colModel: [
{ name: 'conh_id', index: 'conh_id', width: 100, align: 'left' },
{ name: 'numeroc', index: 'numeroc', widht: 100, aligh: 'left' },
{ name: 'datalan', index: 'datalan', width: 150, align: 'left' },
{ name: 'frtotpr', index: 'frtotpr', width: 150, align: 'left' },
{ name: 'municip', index: 'municip', width: 150, align: 'left' },
{ name: 'numfatu', index: 'numfatu', width: 100, align: 'left' }
],
pager: jQuery('#pager'),
rowNum: 10,
rowList: [5, 10, 20, 50],
sortname: 'numeroc',
sortorder: "asc",
viewrecords: true,
imgpath: '/scripts/themes/green/images',
caption: '<b>Relacao de Conhecimentos</b>',
onSelectRow: function (ids) {
if (ids != null) {
var data = $("#list").getRowData(ids);
jQuery("#OrderList").setGridParam({ url: "/agconhs/GetDetailGridData" + data.conh_id, page: 1 })
.setCaption("<b>Order Details for : " + data.numeroc + "</b>")
.trigger('reloadGrid');
}
}
}).navGrid(pager, { edit: false, add: false, del: false, refresh: true, search: false });
jQuery("#OrderList").jqGrid
({
height: 100,
datatype: "json",
colNames: ['conh_id', 'notfis1', 'dataent', 'dataefe', 'obsent1', 'situaca'],
colModel:
[
{ name: 'conh_id', index: 'conh_id', width: 100, align: 'left' },
{ name: 'notfis1', index: 'notfis1', width: 100, align: 'left' },
{ name: 'dataent', index: 'dataent', width: 100, align: 'left' },
{ name: 'dataefe', index: 'dataefe', width: 100, align: 'left' },
{ name: 'obsent1', index: 'obsent1', width: 150, align: 'left' },
{ name: 'situaca', index: 'situaca', width: 150, align: 'left' }
],
rowNum: 5,
rowList: [5, 10, 20],
imgpath: '/scripts/themes/steel/images',
pager: jQuery('#OrderPager'),
sortname: 'notfis1',
viewrecords: true,
sortorder: "desc"
}).navGrid('#OrderPager', { add: false, edit: false, del: false, search: false });
});
</script>
public ActionResult GetDetailGridData(string id, string sidx, string sord, int page, int rows)
{
int startIndex = ((page - 1) * rows) + 1;
int endIndex = page * rows;
string tcQuery = @"SELECT COUNT(*) FROM AGCONH WHERE conh_id =" + Convert.ToInt32(id) ;
string dtQuery = @"With Paged_Ordes AS
(
SELECT conh_id, numeroc, datalan, municip, numfatu,
frtotpr, icmscon, ROW_NUMBER()
OVER (ORDER BY " + sidx + @" " + sord + @") AS rownumber
FROM agconh
WHERE conh_id=" + Convert.ToInt32(id) + @"'
)
SELECT
CONVERT(VARCHAR(10), datalan, 101) datalan,
numeroc, municip, numfatu,
CONVERT(VARCHAR(20), frtotp *100,2) frtotpr,
icmscon
FROM
PAGED_ORDERS
WHERE
rownumber BETWEEN " + startIndex + @" AND " + endIndex + @";";
return Content(JsonHelper.JsonForJqgrid(GetDataTable(dtQuery), rows, GetTotalCount(tcQuery), page), "application/json");
}
public ActionResult GetGridData(string sidx, string sord, int page, int rows)
{
int startIndex = ((page - 1) * rows) + 1;
int endIndex = page * rows;
string tcQuery = @"SELECT COUNT(*) FROM agrnfe";
string dtQuery = @"WITH PAGED_CUSTOMERS AS
(
SELECT
conh_id, dataent, dataefe, obsent1, situaca,
ROW_NUMBER() OVER (ORDER BY " + sidx + @" " + sord + @") AS RowNumber
FROM
agrnfe
)
SELECT
conh_id,
CONVERT(VARCHAR(10), dataent, 101) dataent,
CONVERT(VARCHAR(10), dataefe, 101) dataefe,
obsent1, situaca
FROM
PAGED_CUSTOMERS
WHERE
RowNumber BETWEEN " + startIndex + @" AND " + endIndex + @";";
return Content(JsonHelper.JsonForJqgrid(GetDataTable(dtQuery), rows, GetTotalCount(tcQuery), page), "application/json");
}
Tks a lot.