0
Answer

How to get rows cell value from JQGrid to Controller Action

Ramu D

Ramu D

11y
3k
1
Hii to all,
I have a requirement that i need to get an two tables data from DataBase & display in JQGrid,i have done this using EntityFramework & LINQ in MVC3,here i have one more requirement that where iam facing problem,in addition to the table data i need to display one more column with ActionLinks,whenever user click on ActionLink the respective columns ID(i.e respective rows cell data) i need to get in the controller.This is how i tried by writing my JQGrid code to meet my requirement.
$("#emp-data-grid").jqGrid({
        datatype: "local",
        data: mdata,
        colNames: ["EmployeeID", "EmpName", "Designation", "Salary", "MobileNo", "Email", ""],
        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: 'Link', formatter: function (cellvalue, options, rowObject) {
var x = '@Html.ActionLink("EDIT", "Edit", "Home", new { EmployeeID = "id" }, new { @style = "color:Blue;font-weight:bold;" })';
                    return x.replace("id", rowObject[1]);
                }, align: 'left', width: 100,editurl: ' / Home / Edit / '
            }
            ],
 
        shrinkToFit: true,
        viewrecords: true,
        sortorder: 'asc'
      caption: "Employee List"
    });
This is my Controller Code:-
 public ActionResult Edit(int? id)
{
 return view();
}
In the above controller i want to access id and send to view for displaying that id in some textbox,using viewdata. Please guide me where iam doing mistake,...
 Thanks
 Ramu