I have an jquery grid and want to delete, edit from grid.
My question is how get the selected row ID
<script type="text/javascript">
$(document).ready(function () {
$("#Jgrid").jqGrid({
caption: "SubCatagory",
url: '/api/SubCatagory/GetAllSubcatagoryGrid',
datatype: "json",
mtype: 'GET',
contentType: "application/json; charset-utf-8",
colNames: ['SubCatagory ID', 'SubCatagory Name', 'SubCatagory Code', 'CatagoryId'],
colModel: [
{ key: true, hidden: true, name: 'SubCatagoryId', index: 'SubCatagoryId', editable: true },
{ key: false, name: 'SubCatagoryName', index: 'SubCatagoryName', editable: true },
{ key: false, name: 'SubCatagoryCode', index: 'SubCatagoryCode', editable: true },
{ key: false, name: 'CatagoryId', index: 'CatagoryId', editable: true }
],
pager: jQuery('#pager'),
rowNum: 10,
rowList: [10, 20, 30, 40],
height: '100%',
viewrecords: true,
caption: 'SubCatagory List',
emptyrecords: 'No records to display',
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
Id: "0"
}
}).navGrid('#pager', { edit: true, add: true, del: true, search: false, refresh: true },
{
zIndex: 100,
url: '/api/SubCatagory/EditSubCatagoryId/',
closeOnEscape: true,
closeAfterEdit: true,
recreateForm: true,
afterComplete: function (response) {
if (response.responseText) {
alert(response.responseText);
}
}
},
{
zIndex: 100,
url: "/api/SubCatagory/AddSubCatagoryId/",
closeOnEscape: true,
closeAfterAdd: true,
afterComplete: function (response) {
if (response.responseText) {
alert(response.responseText);
}
}
},
{
zIndex: 100,
url: "/api/SubCatagory/DeleteSubCatagoryId/",
datatype: "json",
mtype: 'Delete',
contentType: "application/json; charset-utf-8",
closeOnEscape: true,
closeAfterDelete: true,
recreateForm: true,
msg: "Are you sure you want to delete this task?",
afterComplete: function (response) {
if (response.responseText) {
alert(response.responseText);
}
}
});
});
</script>
<table id="Jgrid"></table>
<div id="pager"></div>