When i try to replace a value of a grid item with a resource string:
columns.Bound(a => Activities.ResourceManager.GetString(a.ActivityName.ToString())).Title(
"Activity");
(a.ActivityName contains a resource key)
I get:
"Bound columns require a field or property access expression"
Any idea?
3 Answers, 1 is accepted
The exception says it all - the grid supports only member expressions for bound column definition. You can instead set the template of the column:
columns.Bound(a => a.ActivityName).Template(a =>
{
%>
<%= Activities.ResourceManager.GetString(a.ActivityName.ToString())) %>
<%
});
Atanas Korchev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Html.Telerik().Grid<
Activity>().Name("TrackActivitiesGrid")
.DataKeys(a => a.Add(
"ActivityId"))
.Columns(columns =>
{
columns.Bound(a => a.CreatedUTC).Format(
"{0:M.dd.yyyy @ hh:mm}").Title("Date/Time");
columns.Bound(a => a.ActivityName).Title(
"Activity").Template(a => { Activities.ResourceManager.GetString(a.ActivityName); });
columns.Bound(a => a.UserFirstName).Title(
"User")
.ClientTemplate(
"<div class='vtip' title='User Name: <#= UserName #>'><#= UserFirstName #> <#= UserLastName #></div>");
columns.Bound(a => a.UnitCount).Title(
"# Units");
columns.Bound(a => (a.InProgressCount)).Title(
"Progress")
.ClientTemplate(
"<div>" +
"<#= CanceledCount #>, " +
"<#= CompletedCount #>, " +
"<#= FaultedCount #>, " +
"<#= InProgressCount #>, " +
"<#= NoneCount #>, " +
"<#= OverriddenCount #>" +
"</div>");
columns.Bound(a => a.ActivityID).Title(
"").Width(80).Sortable(false)
.ClientTemplate(
"<div>" +
"<div class='cancel-activity fleft' title='Cancel' data-activity-id='<#= ActivityID #>' data-completed-count='<#= CompletedCount #>' data-service-url='TrackActivities/CancelActivity'></div>" +
"<a href='/ActivitiesDrillDown/ActivityChanges?activityId=<#= ActivityID #>' ><div class='activity-drill-down fright' title='View activity changes'></div></a>" +
"</div>");
})
.DataBinding(dataBinding => dataBinding.Ajax().Select(
"_PageOnScroll", "TrackActivities"))
.ClientEvents(events => events.OnLoad(
"TrackActivities.onGridLoad"))
.Sortable(sorting => sorting
.SortMode(
GridSortMode.MultipleColumn)
)
.Pageable(paging => paging.Style(
GridPagerStyles.Status)
.PageOnScroll(
true))
.Render();
The above leads to another exception:
Cannot use only server templates in Ajax or WebService binding mode. Please specify a client template as well
THNX
Alon
I am afraid this won't work for ajax binding. There is no way to access server side localization objects from client-side. As a workaround I can suggest to localize the properties before sending them to the grid in your Select action method. The other option is to use server binding.
Regards,Atanas Korchev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items