This question is locked. New answers and comments are not allowed.
Hi, I keep getting the Grid empty, but the Model is populated, any help will be appreciated. The grid is on a partial view, here is the view:
The partial view is render on a normal view:
And the model data is populated on the controller action:
I have checked that the model is populated, but all I get is an empty table on the page.
<% Html.Telerik().Grid<AgdataFtp.WebUI.Models.EntityPermissions>() .Name("Grid") .Columns(col => { col.Bound(Model.EntityName).Title("Business Group"); col.Template(o => { for (int i=0; i < Model.EffectivePermissions.Count; i++) { %> <table cellspacing="0" class="data-row"> <tr> <td> <%= Html.Encode(Model.EffectivePermissions[i].UserName) %> </td> </tr> <tr> <td> <input type="checkbox" name="DownloadAccessChecked" checked=" <%= Html.Encode(Model.EffectivePermissions[i].DownloadAccess)%> "/> </td> <td> <input type="checkbox" name="DownloadAccessChecked" checked="<%= Html.Encode(Model.EffectivePermissions[i].UploadAccess)%> "/> </td> <td> <input type="checkbox" name="NotifyDownloadChecked" checked="<%= Html.Encode(Model.EffectivePermissions[i].GetNotifyStatus())%> "/> </td> <td> <input type="checkbox" name="NotifyUploadChecked" /> </td> </tr> </table> <% } }).Width(270) .HeaderTemplate(() => { %> <table cellspacing="0" class="data-header"> <tr> <td colspan="4" align="center"> <strong>User</strong> </td> </tr> <tr> <td colspan="2" align="center"> <strong>Access</strong> </td> <td colspan="2" align="center"> <strong>Notification</strong> </td> </tr> <tr> <td>Download</td> <td>Upload</td> <td>Download</td> <td>Upload</td> </tr> </table> <% }) .HeaderHtmlAttributes(new { style = "text-align:center" }) .HtmlAttributes(new { style = "text-align:center" }) .Width(270); }) .Footer(false) .Render(); %>The partial view is render on a normal view:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<AgdataFtp.WebUI.Models.GridPermissionsModel>" %><asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> ExternalPermissions</asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <div class="indent"> <div class="clear"> <% if (Model.BGNames != null) { %> <%= Html.Telerik().ComboBox().Name("BG_DropDownList") .BindTo(new MultiSelectList(Model.BGNames)).SelectedIndex(0) %> <% } %> <%= Html.Telerik().ComboBox().Name("Client_DropDownList") .BindTo(new MultiSelectList(Model.CNames)).SelectedIndex(0) %> <%= Html.Telerik().ComboBox().Name("User_DropDownList") .BindTo(new MultiSelectList(Model.UNames)).SelectedIndex(0) %> </div> <div class="clear"></div> <div> <% foreach (var ep in Model.userBGPermissions) { Html.RenderPartial("CreateGrid", ep);
} %> </div> </div></asp:Content>And the model data is populated on the controller action:
public ActionResult ExternalPermissionsUpdate() { if (loggedUser.UserRol == "Administrator") { gridModel.BGNames = sqlRepository.GetAllBusinessGroups(); gridModel.CNames = sqlRepository.GetAllClients(); gridModel.UNames = sqlRepository.GetActiveUsers(); } else { gridModel.CNames = sqlRepository.GetClientForUser(loggedUser.UserName); gridModel.UNames = sqlRepository.GetActiveUsers(loggedUser.UserName); } //Permissions x User for (int i = 0; i < gridModel.BGNames.Count; i++) { gridModel.AddBusinessGroupPermission(gridModel.BGNames[i], sqlRepository.GetBusinessGroupPermissions(gridModel.BGNames[i])); gridModel.AddClientPermission(gridModel.BGNames[i], sqlRepository.GetClientPermissions(gridModel.BGNames[i])); } ViewData.Model = gridModel; return View("ExternalPermissionsUpdate"); }I have checked that the model is populated, but all I get is an empty table on the page.