This question is locked. New answers and comments are not allowed.
Hi,
I' ve trying to rebind a grid that I have with columns template, the column display a partial view, but I can't get the grid to update its data. The update of the grid is based on other fields on the view.
How can I make this?
Here is the view
The partial view renders a grid itself:
And the controller method:
The grid renders fine with the server data, but I can't get to rebind it with the json object, I' ve also tried with an action method, not returning a json result, but no sucess either, I am not sure if the client template is well defined.
Any help that can point me in the right direction......
Thanks,
I' ve trying to rebind a grid that I have with columns template, the column display a partial view, but I can't get the grid to update its data. The update of the grid is based on other fields on the view.
How can I make this?
Here is the view
<script type="text/javascript">
function ComboBoxClients_onChange(e) {
var combobox_client = $('#ComboBox_Client').data('tComboBox');
var value = combobox_client.value();
}
$(document).ready(function () {
$("#ApplyFilter_Btn").click(function () {
var combobox_client = $("#ComboBox").data("tComboBox");
var value_client = combobox_client.value();
var grid = $("#PermissionsGrid").data("tGrid");
var value_user = $('#ComboBox_User').data('tAutoComplete');
$.ajax({
type: "GET",
url: "<%= Url.Action("GetPermissionsForClient", "PermissionsSetting") %>",
data: ({'c_id': value_client, 'u_list' : value_user.value()}),
dataType: "json",
success: function (d) {
if ($.isEmptyObject(d)) {
return;
}
if (!d.Result) {
alert(d.ErrorMessage[0].ErrorMessage);
}
else {
grid.rebind(d.Data);
}
return;
}
});
});
});
</script>
<div class="filter_header">
<div class="column1">
<label>Client</label><% Html.RenderAction("ShowList", "ClientList"); %>
</div>
<div class="column2">
<label for="ComboBox_User">
User
</label>
<% Html.Telerik().AutoComplete()
.Name("ComboBox_User")
.BindTo(Model.UserList.Select(u => u.Text))
.Filterable(filtering =>
{
filtering.FilterMode(AutoCompleteFilterMode.StartsWith);
})
.Multiple(multi =>
{
multi.Separator(",")
.Enabled(true);
})
.HtmlAttributes(new { @class = "user_list" })
.Render();
%>
</div>
<button class="t-button t-button-icontext" type="button" id="ApplyFilter_Btn">
<span class="t-icon t-refresh"></span>Apply Filters</button>
</div>
<% Html.Telerik().Grid<Models.ClientPermissions>() .Name("PermissionsGrid") .BindTo(Model.ForUpdatePermissions) .Columns(col => { col.Bound(o => o.ClientName).Title("Client"); col.Template(o => { %> <% Html.RenderPartial("CreateGrid", o); }) .ClientTemplate( "<table><tr><td>" + "<#= ClientName #></td>" + "<td><table><tr><td><input type='hidden' value='" + "<#= UserAdId #>" + "/>" + "<input type='checkbox' name='DownloadAccessChecked' checked='" + "<#= DownloadAccess #>" + " /> " + "</td><td><input type='checkbox' name='UploadAccessChecked' checked='" + "<#= UploadAccess #>" + "/>" + "</td><td><input type='checkbox' name='NotifyDownloadChecked' checked='" + "<#= GetNotifyStatus() #>" + "/>" + "</td><td><input type='checkbox' name='NotifyUploadChecked' checked='" + "<#= GetNotifyStatus() #>" + "/>" + "</td></tr></table>" ) .HeaderTemplate(() => { %> <strong>Effective Permissions for Group: <%= Html.Encode(Model.ManagedGroupDesc)%></strong> <% }); }) .DataBinding(d => d.Ajax().Select("GetPermissionsForClient", "PermissionsSetting")) .Footer(false) .Render(); %>The partial view renders a grid itself:
<% Html.Telerik().Grid<Models.UserPermissions>() .Name("Grid") .EnableCustomBinding(true) .BindTo(Model.EffectiveClientPermissions) .Columns(col => { col.Bound(o => o.UserName).Title("User"); col.Template(o => {%><table cellspacing="0" class="data-row"> <tr> <td> <input type="hidden" value=" <%= Html.Encode(o.UserAdId) %>" /> <input type="checkbox" name="DownloadAccessChecked" checked="<%= Html.Encode(o.DownloadAccess) %>" /> </td> <td> <input type="checkbox" name="UploadAccessChecked" checked="<%= Html.Encode(o.UploadAccess)%> " /> </td> <td> <input type="checkbox" name="NotifyDownloadChecked" checked="<%= Html.Encode(o.GetNotifyStatus())%> " /> </td> <td> <input type="checkbox" name="NotifyUploadChecked" checked="<%= Html.Encode(o.GetNotifyStatus())%> "/> </td> </tr></table><% }).Width(270) .HeaderTemplate(() => { %><table cellspacing="0" class="data-header"> <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(); %>And the controller method:
[GridAction] [RequiresAuthentication] public JsonResult GetPermissionsForClient(short? c_id, string u_list) { JsonResult result; short client_id; short bg_id = Repository.GetUserBusinessGroup(AuthenticationService.GetAuthenticatedUserName()).Business_Group_ID; if (c_id.HasValue && c_id != null) { client_id = (short)c_id; string[] user_list = u_list.ToString().Split(','); result = Json(new GridModel<ClientPermissions> { Data = new List<ClientPermissions> { GetPermissionsforClient(client_id, bg_id, user_list) } }); } else result = Json(new GridModel { Data = "" }); return Json(result, JsonRequestBehavior.AllowGet); }The grid renders fine with the server data, but I can't get to rebind it with the json object, I' ve also tried with an action method, not returning a json result, but no sucess either, I am not sure if the client template is well defined.
Any help that can point me in the right direction......
Thanks,