We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Concatenating two Strings with an ExpressionField

Thread ID:

Created:

Updated:

Platform:

Replies:

117483 Oct 29,2014 01:24 AM Nov 3,2014 12:49 AM Windows Forms 6
loading
Tags: GridControl
Gregor
Asked On October 29, 2014 01:24 AM

I need to concatenate string values from two columns in a GridGroupingControl, I tried to do it with the ExpressionField, which works well with number fields, but has no operators to add two strings. So I tried to create my own function and add it with ExpressionFieldEvaluator.AddFunction, but it does not work correctly. The values that it receives from the two columns are something like "bj1,d1". What should that mean?
Here is my code:
        Me.WFMGridGroupingControl.TableDescriptor.ExpressionFieldEvaluator.
                AddFunction("getVendor", New Syncfusion.Grouping.ExpressionFieldEvaluator.LibraryFunction(AddressOf ComputeCustomAdd))

        Dim newExpr As Syncfusion.Grouping.ExpressionFieldDescriptor = New Syncfusion.Grouping.ExpressionFieldDescriptor()
        newExpr.Expression = "getVendor('[Todoby],[Generator]')"
        newExpr.Name = "VendorEXPR"
        newExpr.ResultType = "System.String, mscorlib"
        Me.Tab_WFM_PROCESSGridGroupingControl.TableDescriptor.ExpressionFields.Add(newExpr)

    Public Function ComputeCustomAdd(arguments As String) As String
        Return ("arguments are: " & arguments)
    End Function

The result that is displayed in the grid is: "arguments are: bj1,d1". The values in the columns Todoby and Generator are displayed correctly in the grid.
Can you help me with this problem?


Neelakandan Kannan [Syncfusion]
Replied On October 29, 2014 07:06 AM

Hi Gregor,

 

Thank you for your interest in Syncfusion products.

 

If you want to define the custom expression field descriptor for expression column, you need to define the string concatenation in ComputeFunc method. Please make use of below code and attached sample,

 

Dim evaluator As ExpressionFieldEvaluator = Me.gridGroupingControl1.TableDescriptor.ExpressionFieldEvaluator
evaluator.AddFunction(
"CONCATENATE"New Syncfusion.Grouping.ExpressionFieldEvaluator.LibraryFunction(ComputeFunc))
Dim f2 As ExpressionFieldDescriptor = New ExpressionFieldDescriptor("Result2""CONCATENATE([Val1],[Val2])")
gridGroupingControl1.Engine.TableDescriptor.ExpressionFields.Add(f2)

 

Public Function ComputeFunc(ByVal As StringAs String
        Dim 
comma As Char Convert.ToChar(Me.gridGroupingControl1.Culture.TextInfo.ListSeparator)
        
Dim ss() As String = s.Split(comma)
        
Dim str1 As String = ss(0)
        
Dim str2 As String = ss(1)
        
Return (str1 + str2)
    
End Function

 

Please let me know if you have any concerns.

 

Regards,

Neelakandan


Attachment: Expression_Column_Customization_VB_f95e0345.zip

Gregor
Replied On October 29, 2014 08:06 AM

Hi Neelakandan,
thank you for your answer. I am sorry to say, however, that you have not read my post nor my code exactly. If you had read it, you would have seen that I wrote the code exactly as described on the Syncfusion help pages.
The problem is that the parameter for the delegate function (ComputeFunc in your example) is not passed correctly. The error appears in your example too.
I have attached two screenshots for you to see the problem.
Can the reason for it be the Version of the Syncfusion controls? I use the version 11.1.0.21.
Regards,
Gregor.

Attachment: Screenshots_e8ef04f8.zip

Neelakandan Kannan [Syncfusion]
Replied On October 30, 2014 07:57 AM

Hi Gregor,

 

Regret for the inconvenience caused.

 

We analyzed your scenario at our end. We could not able to reproduce an issue in 11.1.0.21 version that you are mentioned in your last update. Please refer the below code and customize your expression function as per below code and also please refer the below attached sample video,

 

Dim evaluator As ExpressionFieldEvaluator = Me.gridGroupingControl1.TableDescriptor.ExpressionFieldEvaluator

evaluator.AddFunction("CONCATENATE", New Syncfusion.Grouping.ExpressionFieldEvaluator.LibraryFunction(AddressOf ComputeFunc))

Dim newExpr As New ExpressionFieldDescriptor("Result2", "CONCATENATE([Val1],[Val2])")

gridGroupingControl1.Engine.TableDescriptor.ExpressionFields.Add(newExpr)

 

Please refer the below UG link:

http://help.syncfusion.com/ug/windows%20forms/default.htm#!Documents/howtoaddcustomcalcul.htm

 

Please let me know if you have any concerns.

 

Regards,

Neelakandan


Attachment: Sample_and_Video_33b478fa.zip

Gregor
Replied On October 31, 2014 11:35 AM

Hello,
those were the two most useless answers I have ever read.
Is there anyone out there who is willing to read my posts, understand them and help me with my problem?
Gregor.

Vinish Kumar K [Syncfusion]
Replied On November 3, 2014 12:46 AM

Hello,
those were the two most useless answers I have ever read.
Is there anyone out there who is willing to read my posts, understand them and help me with my problem?
Gregor.

Hi Gregor,

 

We deeply regret for the inconvenience caused,

 

We have analyzed the reported issue in our end, GGC returns “Invalid Expression” error while you have used the custom function name as “GETVENDOR”. Because some issues are occurring in our source while parse the formula text. So please use any suitable name for your methods. Here we have modified the name as “CONC” please refer the below code.

 

evaluator.AddFunction("CONC", New Syncfusion.Grouping.ExpressionFieldEvaluator.LibraryFunction(AddressOf ComputeCustomAdd))

            Dim f2 As New ExpressionFieldDescriptor("Result2", "CONC([Val1],[Val2])")

 

 

So please refer the attached sample and image also this will resolve the reported issue in your end and it returns the proper solution as you expected in ypur end.  Fix for this issue will be included in our main volume release 2014 Vol 4. If you need fix as earlier that volume release please create incident using your Direct trac account, we will provide fix as earlier.

 

 

 

Regards,

Vinish Kumar, 


Vinish Kumar K [Syncfusion]
Replied On November 3, 2014 12:49 AM

Hi Gregor,

Refer the attached sample file 

Let me know if you have any concerns.

Regards,
Vinish K

Attachment: Expression_Column_Customization_VB_cb10a58.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;