0

i want to show data in jqgrid but data is not showing my controller code is below

 public JsonResult getjqgriddata()
    {

        var emp=from v in ent.employees select v;
     var    users = emp.ToArray();

       return Json(users, JsonRequestBehavior.AllowGet);
    }

my view code is below

    <link  rel="stylesheet" href="~/Content/ui.jqgrid.css"  type="text/css"/>
@*<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>*@
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script src="~/Scripts/grid.locale-en.js" type="text/javascript"></script>
<script src="~/Scripts/jquery.jqGrid.min.js" type="text/javascript"></script>
<script>
    $(document).ready(function () {

        $("#jqTable").jqGrid({
            url: "/HelloWorld/getjqgriddata",
            datatype: "json",
            mtype: "get",

            colNames: ["FirstName", "Id", "LastName", "Phone"],
            colModel: [
                 { name: "FirstName", Index: "FirstName", width: "40px", align: "left" },
                  { name: "Id", Index: "Id", width: "40px", align: "left" },
                  { name: "LastName", Index: "LastName", width: "40px", align: "left" },
                   { name: "Phone", Index: "Phone", width: "40px", align: "left" } ],
            width: 550,
            height: 200,
            rowNum: 1,
            jsonReader: { repeatitems: false, root: function (obj) { return obj; } },
            gridview: true,





            viewrecords: true, // Specify if "total number of records" is displayed

        });


    });





</script>



<div>
        <table id="jqTable" class="scroll"></table>
        <div id="jqTablePager" />
    </div>

i want to know that when json res is sent from controller than how data is view in view plz help thanks in advance

abiansh
  • 79
  • 2
  • 2
  • 9

1 Answers1

0

You have to return json data from the action method in a specific format. For more details, refer this link:

jqgrid in asp.net using json datatype

Community
  • 1
  • 1
Sharun
  • 3,022
  • 6
  • 30
  • 59