about expression

3 posts, 0 answers
  1. Ada
    Ada avatar
    3 posts
    Member since:
    Jul 2012

    Posted 19 Nov 2015 Link to this post

    Hi There,


    I am using expression to define some special function for the format.

    I have 2 questions:

    1) my function is like

    Public Class CustomExpressionContext
        Inherits Telerik.Data.Expressions.ExpressionContext
        Public Function formatAddress(ClientName As String, rawAdd As String) As String
            rawAdd = rawAdd.Replace("{}", vbCrLf)
            rawAdd = rawAdd.Replace("{lf}", ClientName & vbCrLf)
            rawAdd = rawAdd.Replace(vbCrLf & vbCrLf, vbCrLf)
            Return rawAdd
        End Function
    End Class

    when I use ColumnRawAdd.expression = "formatAddress(AliasName, RawAddresses)"   where ColumnRawAdd is the column for "RawAddresses"

    I got exception like "RawAddresses is not defined in the context"

    if I use a new column, and set newcolumn.expression = "formatAddress(AliasName, RawAddresses)"  

    then there is no problem. Is there something I need to set or check for ColumnRawAdd so I can use ColumnRawAdd for it?


    2)newcolumn is working fine, but if I LoadLayout for alll the columns first, then define newcolumn.expression = "formatAddress(AliasName, RawAddresses)"  

    then the newcolumn is empty, without any exception. What should I do here to have newcolumn have value?





  2. Ada
    Ada avatar
    3 posts
    Member since:
    Jul 2012

    Posted 23 Nov 2015 Link to this post

    Nobody answered?
  3. Dess
    Dess avatar
    2107 posts

    Posted 24 Nov 2015 Link to this post

    Hello Ada,

    Thank you for writing.

    Firstly, I would like to note that most of the forum threads are reviewed by Telerik representatives and we address the questions asked by our customers in the forums as well. Additionally, have in mind that the ticket response time for forum threads is 72 hours. So if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread.

    As to the question at hand, when you set a custom ExpressionContext where you define a custom function to calculate the cell value, note that the exact column name can't be used inside its Expression because you are currently executing the value for this column and you should not require its value to calculate its own value. I would recommend you to use the CellFormatting event and set the cell's Text property in order to achieve the desired format.

    I hope this information helps. Should you have further questions I would be glad to help.
    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 Feedback Portal and vote to affect the priority of the items
Back to Top