使用web api Mvc 4从jgrid中删除 [英] delete from jgrid using web api Mvc 4
本文介绍了使用web api Mvc 4从jgrid中删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个jquery网格,想删除,从网格编辑。
我的问题是如何获取所选行ID
< script type =text / javascript>
$(document).ready(function(){
$(#Jgrid)。jqGrid({
caption:SubCatagory,
url: '/ api / SubCatagory / GetAllSubcatagoryGrid',
数据类型: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',编辑able:
],
pager:jQuery('#pager'),
rowNum:10,
rowList:[10,20,30,40 ],
身高:'100%',
viewrecords:true,
标题:'SubCatagory List',
emptyrecords:'没有要显示的记录',
jsonReader :{
root:rows,
page:page,
total:total,
记录: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 /,//我想在这里选择Id使用+符号
数据类型:json,
mtype:'删除',
contentType:application / json; charset-utf-8,
closeOnEscape:true,
closeAfterDelete:true,
recreateForm:true,
msg:你确定要删除此任务吗? ,
afterComplete:function(response){
if(response.responseText){
alert(response.responseText);
}
}
});
});
< / script>
< 表 id = Jgrid > < / table >
< div id = pager > < / div >
解决方案
(document).ready(function(){
( #Jgrid).J qGrid({
标题:SubCatagory,
url:'/ api / SubCatagory / GetAllSubcatagoryGrid',
数据类型: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}
],
寻呼机:jQuery('#pager'),
rowNum:10,
rowList:[10,20,30,40],
身高:'100%',
viewrecords:true,
标题:'SubCatagory List',
emptyrecords:'否记录显示',
jsonReader:{
root:rows,
page:page,
total:total,
记录:记录,
repeatitems:false,
Id:0
}
})。navGrid('#pager',{edit:true,add:true,del:true ,搜索:false,刷新: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 /,//我想在这里选择Id使用+符号
数据类型:json,
mtype:'删除',
contentType:application / json; charset-utf-8,
closeOnEscape:true,
closeAfterDelete:true,
recreateForm:true,
msg:你确定要删除此任务吗? ,
afterComplete:function(response){
if(response.responseText){
alert(response.responseText);
}
}
});
});
< / script>
< 表 id = Jgrid > < / table >
< div id = pager > < / div > 跨度>
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 }, { // edit options zIndex: 100, url: '/api/SubCatagory/EditSubCatagoryId/', closeOnEscape: true, closeAfterEdit: true, recreateForm: true, afterComplete: function (response) { if (response.responseText) { alert(response.responseText); } } }, { // add options zIndex: 100, url: "/api/SubCatagory/AddSubCatagoryId/", closeOnEscape: true, closeAfterAdd: true, afterComplete: function (response) { if (response.responseText) { alert(response.responseText); } } }, { // delete options zIndex: 100, url: "/api/SubCatagory/DeleteSubCatagoryId/", // I want selected Id here using + sign 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>
解决方案
(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 }, { // edit options zIndex: 100, url: '/api/SubCatagory/EditSubCatagoryId/', closeOnEscape: true, closeAfterEdit: true, recreateForm: true, afterComplete: function (response) { if (response.responseText) { alert(response.responseText); } } }, { // add options zIndex: 100, url: "/api/SubCatagory/AddSubCatagoryId/", closeOnEscape: true, closeAfterAdd: true, afterComplete: function (response) { if (response.responseText) { alert(response.responseText); } } }, { // delete options zIndex: 100, url: "/api/SubCatagory/DeleteSubCatagoryId/", // I want selected Id here using + sign 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>
这篇关于使用web api Mvc 4从jgrid中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文