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

Grid inside DataForm - expression columns not working

3 Answers 75 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
HDC
Top achievements
Rank 1
HDC asked on 08 May 2011, 09:13 AM

I have made a RadDataForm "Invoice".

In the "Edit Template" i added a RadGridView "InvoiceDetails", this grid has following columns:

Description, Price, Quantity, Total

The Total column is an Expression Column: Total = Price * Quantity.  

Using following code executed in the grid loaded event:

Expression<Func<ExqiOffice.Web.InvoiceDetail, double>> expr = invd => (double)(invd.Price.HasValue == true ? invd.Price : 0.0f) * (double)(invd.Quantity.HasValue ? invd.Quantity : 0.0f);
GridViewExpressionColumn col = ((RadGridView)sender).Columns["Total"] as GridViewExpressionColumn;
col.Expression = expr;      

I placed the grid inside a DataFormDataField. When i run the code and open an invoice, the code takes a long time to execute and then returns a generic error message:

An unhandled exception ('Unhandled Error in Silverlight Application
Code: 4004   
Category: ManagedRuntimeError      
Message: System.ArgumentNullException: [ArgumentNull_Generic]

When i place the grid outside the dataform, the code works perfectly.

Has anyone tried this and found a solution or is this a bug in the RadGridView/RadDataForm combination?
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Yavor Georgiev
Telerik team
answered on 08 May 2011, 10:41 AM
Hi peter,

 I have tried to reproduce this behavior, but unfortunately I could not. Please inspect the attached sample application and let me know if it matches your scenario and if not, what the differences are.

All the best,
Yavor Georgiev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
HDC
Top achievements
Rank 1
answered on 08 May 2011, 10:53 AM
Hi Yavor,

Thanks for your really fast answer (especially on a sunday!)

Yes, this does solve the problem, i was able to make an Expression "Price * Quantity" which effectively solves the problem.

However, please forgive me for saying, but this again proves that the documention of the telerik leaves a lot to be desired!!! I have based my code upon a single snippet of code that i could find within the documentation about expression column. This snippet solves the problem using a lambda expression.

Now it seems it is actually much more simple to achieve using a simple string formula. This is very powerfull, yet i did not find it in the documentation!!

Sorry for the rant, but i think many of your customers will agree with me on this.




0
Yavor Georgiev
Telerik team
answered on 08 May 2011, 11:50 AM
Hi peter,

 The string formula results in a lambda expression, it's just "sugar" we implemented in our SP1 release. You can examine the Expression property of the column and confirm this. Perhaps your original lambda had some fault which evinced itself in the context of RadDataForm.

 The Expression property of GridViewExpressionColumn now uses the engine powering RadExpressionEditor to parse a string to a LambdaExpression. You can experiment with a RadExpressionEditor and see the differences between the lambda it generates and the one you had created originally.

Best wishes,
Yavor Georgiev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
DataForm
Asked by
HDC
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
HDC
Top achievements
Rank 1
Share this question
or