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

about expression

2 Answers 60 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ada
Top achievements
Rank 1
Ada asked on 20 Nov 2015, 05:24 AM

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?

 

Thanks.

 

Ada

2 Answers, 1 is accepted

Sort by
0
Ada
Top achievements
Rank 1
answered on 23 Nov 2015, 08:30 PM
Nobody answered?
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Nov 2015, 01:23 PM
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.
 
Regards,
Dess
Telerik
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
Tags
GridView
Asked by
Ada
Top achievements
Rank 1
Answers by
Ada
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or