This is a migrated thread and some comments may be shown as answers.

[Solved] Resources for row items

3 Answers 35 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ofer
Top achievements
Rank 1
Ofer asked on 11 Aug 2011, 08:05 AM
Hi,
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

Sort by
0
Atanas Korchev
Telerik team
answered on 11 Aug 2011, 08:10 AM
Hello Alonav,

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())) %>
<%
});

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

0
Ofer
Top achievements
Rank 1
answered on 11 Aug 2011, 09:09 AM
I alreadt tried that. please see my full code- it's with ajax binding (& Razor):

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
0
Atanas Korchev
Telerik team
answered on 11 Aug 2011, 10:03 AM
Hi Alonav,

 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

Tags
Grid
Asked by
Ofer
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Ofer
Top achievements
Rank 1
Share this question
or