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

Bind a TextField to a Method on a Datasources Object

1 Answer 46 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 30 Jul 2014, 10:40 PM
I am trying to source a field from a Method instead of a Property on the Object, is there anyway to accomplish this?

public class MyObject()
{
   public PropertyA{get;set;}
   public string GetValue(string Name)
    { 
        return "XYZ";
    }
}

In my Dynamic Report I am trying to do something like:

rowTextBox.Value = "=GetValue(\"" + columns[i].Name +"\")";
dataTable.DataSource = new List<MyObject>();



But it doesn't appear to find and execute the method.  Any ideas?

1 Answer, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 04 Aug 2014, 08:26 AM
Hello Kevin,

When you write an expression, you have access not only to Global Objects, Functions and Aggregate Functions but you can also access a member of an object, using the . (dot) character. You can call all public members of an object directly in the Expression Editor.
For more information and examples, please refer to the Member Access help article.

You cannot use the GetValue() result in a Fields.GetValue() expression, but the method result can be assigned to a property of the object and then this property can be used in the expression instead of the method.

Another approach is to define a user function and pass to it the Name value as an argument. For more information on extending the expressions with user functions, please check the User Functions help article.

Regards,
Nasko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Kevin
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Share this question
or