This question is locked. New answers and comments are not allowed.
I am passing the following ViewModel to my view page:
When I have the data binding set to dataBinding.Ajax() it works but as soon as I comment that line out it does not bind the ViewModel to the View any more (In debug I can see it passed the model to the view.)
View:
This is my controller part:
I get that the ajax ActionResult passes a sub-set of the View Model but what can I do to get the binding to occur without the Ajax... I want the binding to happen server-side and from that point everything will be done Ajax-style.
Thank you
Jack.
namespace myApp.Domain.ViewModels{ public class ApiAccountAccessKeyViewModel { public List<ApiAccountAccessKey> AccountAccessKeys { get; set; } public myAppUser User { get; set; } public List<SelectListItem> available { get; set; } }}When I have the data binding set to dataBinding.Ajax() it works but as soon as I comment that line out it does not bind the ViewModel to the View any more (In debug I can see it passed the model to the view.)
View:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/SingleColumn.Master" Inherits="System.Web.Mvc.ViewPage<myApp.Domain.ViewModels.ApiAccountAccessKeyViewModel>" %>Lots of HTML here and then: <% Html.Telerik().Grid<myApp.Domain.ApiAccountAccessKey>() .Name("AccountAccessKeyGrid") .DataKeys(dataKeys => dataKeys.Add(k => k)) //.DataBinding(dataBinding => dataBinding.Ajax().Select("AjaxBinding", "API")) .ClientEvents(events => events.OnDataBound("onDataBound")) .Columns(columns => { columns.Bound(k => k.ID).Format("<a href='javascript:void(0)' onclick=editAccessKey('{0}');>" + Resources.Resource.Site_Grid_Edit + "</a>") .Encoded(false).Title(" ").Filterable(false); columns.Bound(k => k.ID).Format("<a href='javascript:void(0)' onclick=deleteAccessKey('{0}');>" + Resources.Resource.Device_Grid_Delete + "</a>") .Encoded(false).Title(" ").Filterable(false); columns.Bound(k => k.AccessKey).Title("Access key").Filterable(true); columns.Bound(k => k.FriendlyName).Title(Resources.Resource.API_Friendly_Name).Filterable(true); columns.Bound(k => k.ExpirationDate).Format("{0:MM/dd/yyyy}").Title(Resources.Resource.API_Expires).Filterable(true); columns.Bound(k => k.IsActive).Title(Resources.Resource.API_Activated).Filterable(true); columns.Bound(k => k.Description).Title(Resources.Resource.API_Accesskey_Description).Filterable(false); }) .Pageable(p => p.PageSize(20)) .Sortable() .Filterable() .HtmlAttributes(new { @class = "content_border_table", style="display:none" }) .Render(); %>This is my controller part:
public ActionResult ListAccessKeys() { var model = new ApiAccountAccessKeyViewModel(); model.AccountAccessKeys = _apiAccountAccessKeyRepository.GetAccessKeysByPartyID(PartyId); model.User = _userRepository.GetByPartyId(PartyId); return View("ListAccessKeys", model); }and the part that actually works: [GridAction] public ActionResult AjaxBinding() { return View(new GridModel(_apiAccountAccessKeyRepository.GetAccessKeysByPartyID(PartyId))); }The repository has: public List<ApiAccountAccessKey> GetAccessKeysByPartyID(int partyID)I get that the ajax ActionResult passes a sub-set of the View Model but what can I do to get the binding to occur without the Ajax... I want the binding to happen server-side and from that point everything will be done Ajax-style.
Thank you
Jack.