Expression Column in GridGroupingControl

Currently my dataTable for the mapped column returns a double. My implementation is roughly as follows:
efd.Expression = "[Score]*100";
efd.Name = "ScorePercent";

I get values like 98.4490849790879

I need to implement something like C# method Math.Round() in my GridGroupingControl Expression column.

Is it possible?

Thank you in advance,

 

    


2 Replies

ES Eswari S Syncfusion Team April 3, 2014 06:18 AM UTC

Hi Alex,

 

Thank you for using Syncfusion products.

 

Your requirement can be achieved by adding custom function to ExpressionFieldEvaluator. Please refer to the following code snippets:

 

// Add function named Func that uses a delegate named ComputeFunc to define a custom calculation

        ExpressionFieldEvaluator evaluator = this.GridGroupingControl1.TableDescriptor.ExpressionFieldEvaluator;

        evaluator.AddFunction("Func", new ExpressionFieldEvaluator.LibraryFunction(ComputeFunc)); 

        Syncfusion.Web.UI.WebControls.Grid.Grouping.GridExpressionFieldDescriptor efd = new GridExpressionFieldDescriptor();

       

        // define expression using custom function.

        efd.Expression = "Func([ID]+ 50.9)";

        efd.Name = "ID + 500";

        this.GridGroupingControl1.TableDescriptor.ExpressionFields.Add(efd);

 

//compute func

  public string ComputeFunc(string s)

    {

        return Math.Round(Convert.ToDecimal(s)).ToString();

    }

 

For your convenience , we have attached the sample.

 

Please try this and let us know if you have any queries.

 

Regards,

Eswari S



ES Eswari S Syncfusion Team April 3, 2014 06:19 AM UTC

Hi Alex,

Please find sample from the attachment.

Regards,
Eswari S

Attachment: 122993_407cdccf.zip

Loader.
Up arrow icon