Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
//== this is my Controller
C#
[OutputCache(Duration = 0)]
       public JsonResult Inventory_Read([DataSourceRequest] DataSourceRequest request)
       {
           var vDealershipsid = 1;
           using (var context = new VehicleSalesProdEntities())
           {
               // Perform data access using the context
               var myinvdata = context.Inventory.Select(a => a.DealershipsDealerId == vDealershipsid);
               return Json(myinvdata, JsonRequestBehavior.AllowGet);
           }
       }





// this is my grid control - partial view - edit and delete code disabled.
C#
@(
 Html.Kendo().Grid<POVSalesPlus.Areas.Inventory.Models.InventoryViewModel>()
        .Name("InventoryGrid")
        .Columns(column =>
        {
            column.Bound(m => m.Id);
            column.Bound(m => m.Year);
            column.Bound(m => m.Make);
            column.Bound(m => m.Model);
            column.Command(command =>
            {
                command.Custom("edit").Text("Edit").Click(
                    @<text>
                        function(e)
                        {
                        @*var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
                            var url = "@Url.Action("Edit", "Employee", new { area = "RMS" })/" + dataItem.Id;
                            window.location.href=url;*@
                        }
                    </text>
                );

                command.Custom("delete").Text("Delete").Click(
                    @<text>
                        function(e)
                        {

                        @*if (confirm("Are you sure you want to delete this employee?"))
                                {
                                  var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
                                  var options = {
                                  url: "@Url.Action("Delete", "Employee", new { area = "RMS" })",
                                  type: "Post",
                                  data: $('<form>@Html.AntiForgeryToken()<input id="id" name="id" type="text" value="' + dataItem.Id + '" /></form>').serialize()
                                };

                                $.ajax(options).done(function(){
                                $("#InventoryGrid").data("kendoGrid").dataSource.read();
                                });

                            }*@
                        }
                    </text>
                );
            });
        })
  .Editable(editable => editable.Mode(GridEditMode.InLine))
  .Pageable()
  .Sortable()
  .DataSource(dataSource => dataSource
  .Ajax()
  .PageSize(20)
  .Model(model => model.Id(p => 1))
  .Read(read => read.Action("Inventory_Read", "Inventory"))
      .Model(model =>
      {
        model.Id(m => m.Id);
      })
  )
)




//========= this is my model
C#
public class InventoryViewModel : Controller
   {


       [Required]
       public int Id { get; set; }

       public string Year { get; set; }
       public string Make { get; set; }
       public string Model { get; set; }

   }
Posted

1 solution

I would rather suggest to ask this question at Telerik/Kendo forums. You would get a better audience for this question who are more experienced with this specific component.

http://www.telerik.com/forums/kendo-ui[^]
 
Share this answer
 
Comments
dwhite4 16-Nov-14 23:18pm    
Is it possible to populate a Kendo Grid this way?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900