Bind a TextField to a Method on a Datasources Object

2 posts, 0 answers
  1. Kevin
    Kevin avatar
    5 posts
    Member since:
    Jun 2008

    Posted 30 Jul 2014 Link to this post

    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?
  2. Nasko
    Admin
    Nasko avatar
    1051 posts

    Posted 04 Aug 2014 Link to this post

    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.

     
Back to Top