Grid inside DataForm - expression columns not working

4 posts, 1 answers
  1. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 08 May 2011 Link to this post

    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?
     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

  2. Answer
    Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 08 May 2011 Link to this post

    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
  3. DevCraft banner
  4. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 08 May 2011 Link to this post

    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.




  5. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 08 May 2011 Link to this post

    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
Back to Top