Using viewmodelpage in read action

2 posts, 0 answers
  1. Houssem
    Houssem avatar
    4 posts
    Member since:
    Jul 2015

    Posted 03 Sep 2015 Link to this post

    Hello,

    I need to use my viewmodelpage in my read action of kendo mvc grid. This my codes :

    #Controller

     VolViewModel model;

    public ActionResult Index()
    {
    model = new VolViewModel { Item = new List<Vol>() };
    model.Item = _volBusiness.GetAllVol();
    return View(model);
    }

    [System.Web.Mvc.AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Read([DataSourceRequest]DataSourceRequest request)
    {
    var result = model.Item;
    return Json(result.ToDataSourceResult(request));
    }

     

    #Index.cshtml

    .DataSource(dataSource => dataSource
    .Ajax()
    .ServerOperation(false)
    .PageSize(15)
    .Model(model =>
    {
    model.Id(m => m.VolId);
    })
    .Read(read => read.Action("Read", "Vol")
    )

     

    Thanks,

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2291 posts

    Posted 07 Sep 2015 Link to this post

    Hello Houssem,

    Note that you should specify the exact name of the action and the controller. Check out the following article for illustration:


    Regards,
    Viktor Tachev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top