如何使用MVC3将ActionLink保留到JQGrid的每一行 [英] How to keep a ActionLink to each row of the JQGrid using MVC3

查看:63
本文介绍了如何使用MVC3将ActionLink保留到JQGrid的每一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hii to all,

我已成功完成,从数据库中获取表数据并在JQGrid中显示。现在我想再向我的JQGrid添加一列,应该是一个ActionLink说编辑,即我想在我的JQGrid的每一行添加一个链接按钮,这样每当用户点击ActionLink时,它必须重定向到另一个视图,并且它必须得到相应的行数据说一些单元格值(id) ..这是我的JQGrid



$(#emp-data-grid)。jqGrid({

datatype:local ,

数据:mdata,

colNames:[EmployeeID,EmpName,Designation,Salary,MobileNo,Email,EDIT ],

colModel:[

{名称:EmployeeID,索引:EmployeeID,可排序:false,

editable:true ,edittype:'checkbox',editoptions:{value:'true:false'}

},

{name:EmpName,index:EmpName},

{name:Designation,index:Designation},

{name:Salary,index:Salary,sorttype: int},

{名称:MobileNo,索引:MobileNo,sorttype:int},

{名称:电子邮件,索引: Email},

{name:'EditAction',formatter:'showlink',formatoptions:{baseLinkUrl:'@ Url.Action(Edit)'}}, b $ b],



shrinkToFit:true,

viewrecords:true,

sortorder:'asc' ,

标题:员工名单

});



我尝试了以下但是没有获取链接列

名称:'EditAction',格式化程序:'showlink',formatoptions:{baseLinkUrl:'@ Url.Action(编辑)'}},



请帮帮我怎样才能显示每一行的链接..提前谢谢



谢谢

Ramu

Hii to all,
I have done successfully,in getting the tables data from database & displayed in JQGrid.Now i want to add one more column to my JQGrid that should be an ActionLink say "EDIT",i.e i want to add a Link button to each row of my JQGrid,so that whenever user clicked on ActionLink it has to redirect to another View,and also it has to get the respective row data say some cell value(id)..This is my JQGrid

$("#emp-data-grid").jqGrid({
datatype: "local",
data: mdata,
colNames: ["EmployeeID", "EmpName", "Designation", "Salary", "MobileNo", "Email", "EDIT"],
colModel: [
{ name: "EmployeeID", index: "EmployeeID", sortable: false,
editable: true, edittype: 'checkbox', editoptions: { value: 'true:false' }
},
{ name: "EmpName", index: "EmpName" },
{ name: "Designation", index: "Designation" },
{ name: "Salary", index: "Salary", sorttype: "int" },
{ name: "MobileNo", index: "MobileNo", sorttype: "int" },
{ name: "Email", index: "Email" },
{ name: 'EditAction', formatter: 'showlink', formatoptions: { baseLinkUrl: '@Url.Action("Edit")'} },
],

shrinkToFit: true,
viewrecords: true,
sortorder: 'asc',
caption: "Employee List"
});

I have tried with the following but didn't get the Links column
name: 'EditAction', formatter: 'showlink', formatoptions: { baseLinkUrl: '@Url.Action("Edit")'} },

Please help me how can i show a links to each row..Thanks in advance

Thanks
Ramu

推荐答案

(#emp-data-grid)。jqGrid({

datatype:local,

数据:mdata,

colNames:[EmployeeID,EmpName,指定,薪水,MobileNo,电子邮件,编辑 ],

colModel:[

{名称:EmployeeID,索引:EmployeeID,可排序:false,

可编辑:true, edittype:'checkbox',editoptions:{value:'true:false'}

},

{name:EmpName,index:EmpName},

{name:Designation,index:Designation},

{name:Salary,index:Salary,sorttype:int},

{name:MobileNo,index:MobileNo,sorttype:int},

{name:Email,index:Email},

{name:'EditAction',formatter:'showlink',formatoptions:{baseLinkUrl:'@ Url.Action(Edit)'}},

],



shrinkToFit:true,

viewrecords:true,

sortorder:'asc',

标题:员工名单

});



我尝试了以下但未获得Links列

名称:'EditAction',格式化程序:'showlink',formatoptions:{baseLinkUrl:'@ Url.Action(Edit)'}},



请帮帮我如何显示每一行的链接..提前谢谢



谢谢

Ramu
("#emp-data-grid").jqGrid({
datatype: "local",
data: mdata,
colNames: ["EmployeeID", "EmpName", "Designation", "Salary", "MobileNo", "Email", "EDIT"],
colModel: [
{ name: "EmployeeID", index: "EmployeeID", sortable: false,
editable: true, edittype: 'checkbox', editoptions: { value: 'true:false' }
},
{ name: "EmpName", index: "EmpName" },
{ name: "Designation", index: "Designation" },
{ name: "Salary", index: "Salary", sorttype: "int" },
{ name: "MobileNo", index: "MobileNo", sorttype: "int" },
{ name: "Email", index: "Email" },
{ name: 'EditAction', formatter: 'showlink', formatoptions: { baseLinkUrl: '@Url.Action("Edit")'} },
],

shrinkToFit: true,
viewrecords: true,
sortorder: 'asc',
caption: "Employee List"
});

I have tried with the following but didn't get the Links column
name: 'EditAction', formatter: 'showlink', formatoptions: { baseLinkUrl: '@Url.Action("Edit")'} },

Please help me how can i show a links to each row..Thanks in advance

Thanks
Ramu


使用jqGrid中的自定义格式化程序添加如下所示的列以添加actionlink

Add a column like below using custom formatter in jqGrid for adding actionlink
{ name: 'LinkButton',
                         formatter: function (cellvalue, options, rowObject) {
                            var x =  '@Html.ActionLink( "Edit", "Action","Controller",new { requestId ="myId"  }, new {@style="color:Blue;font-weight:bold;"" })';
                             return x.replace("myId",rowObject[7]);
                         },sortable:false, align: 'left', width: 100
                     }







您可以使用 rowObject [columnindex] 获取行索引值。在此示例中,我还将id传递给actionResult





希望这有帮助




you can get row index value by using rowObject[columnindex].In this example i have also pass an id to the actionResult


Hope this helps


http://prajapatipravin.blogspot.in/2015/01/add-custom-action-link-to-jqgrid-row-pravin -prajapati.html [ ^ ]


这篇关于如何使用MVC3将ActionLink保留到JQGrid的每一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆