This is a migrated thread and some comments may be shown as answers.

grid example for mvc 3 json data

1 Answer 212 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ramesh
Top achievements
Rank 1
ramesh asked on 05 Dec 2011, 03:53 PM
hi where can i find best grid example that works with mvc 3 json data.

1 Answer, 1 is accepted

Sort by
0
Voss
Top achievements
Rank 1
answered on 08 Dec 2011, 03:48 PM
ramesh,
Give this a try:  I'm using the change function in this example because i have child properties, but you do not have to.
Let me know if you have any questions:

Controller:
  [AcceptVerbs(HttpVerbs.Get)]
        public JsonResult JsonGetTest1string teamId, string historicalPlayerId)
        {
            var data = GetSomeData();

            return Json(data, JsonRequestBehavior.AllowGet);
        }

View:
<div class="k-content" style="border:1px solid;">
    <table id="gridTeamPlayers">
        <thead>
              <tr>
                <th data-field="Name" style="text-align: left; width: 120px;">Player</th>
              </tr>
        </thead>
    </table>
</div>
@*Schedule*@
<script id="rowTemplate" type="text/x-kendo-tmpl">
    <tr>
        <td style="text-align: left; width: 70px">
                ${ Name }
        </td>
    </tr>
</script>
<script>

    var ds = new kendo.data.DataSource(
        {
            type: "json",
            serverPaging: false,
            serverSorting: false,
            transport:
            {
                read: "JsonGetTest1?teamId=@ViewBag.TeamId"
            },

            change: function () {

                $("#gridTeamPlayers").kendoGrid({
                    dataSource: ds.data().Schedule,
                    height: 400,
                    selectable: "row",
                    scrollable: true,
                    sortable: true,
                    pageable: false,
                    navigatable: true,
                    rowTemplate: kendo.template($("#rowTemplate").html())            

                });

            }

        });

        ds .read();
 
</script>
Tags
Grid
Asked by
ramesh
Top achievements
Rank 1
Answers by
Voss
Top achievements
Rank 1
Share this question
or