display result in expression under condition

5 posts, 0 answers
  1. Johnny
    Johnny avatar
    30 posts
    Member since:
    Jan 2012

    Posted 15 Feb 2012 Link to this post

    hi,

    My grid has an expression column that displays value from other columns. But I would like to be able to control the display value using two equation under certain condition. Since one expression column can only binds to one expression equation. If I would like to control the result displaying in my expression as If (condition 1) { display equation1} else if (condition 2) {display equation 2}, where condition 1 and 2 are depends on the result from other column inside the grid.  How can I able to do that? Thanks.
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 16 Feb 2012 Link to this post

    Hi,

    You can check this forum thread for a reference.

    Regards,
    Didie
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. Johnny
    Johnny avatar
    30 posts
    Member since:
    Jan 2012

    Posted 16 Feb 2012 Link to this post

    Thank you. It works great! I do have one more questions, I am now using
    Expression<func<GridColumns,double>> expression = c => condition ? display1 : display 2; where display2 returns a double value. However, I do want to use display1 to display a string of message to remain the user. I tried double.parse("display_string") and the double.tryparse(string,double%) methods. How can I able to get string display using the above method?

    Another question I have is how can I set up my combo box and expression column so that every time I change the selection from the combo box list, the value behind the selection could automatically change in the expression column without clicking on other columns? It it done by EventTrigger properties?

    Thanks
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 17 Feb 2012 Link to this post

    Hello,

     If your expression is Expression<func<GridColumns,double>>, then it will expect a result of type double. Is the string actually a double value? 

    As to your second question, you could define a CellTemplate/CellEditTemplate for the GridViewColumn and place a ComboBox inside. That way once you change the selection of the ComboBox the expression column should be updated.

    Kind regards,
    Didie
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  5. Johnny
    Johnny avatar
    30 posts
    Member since:
    Jan 2012

    Posted 21 Feb 2012 Link to this post

    Thanks for your reply. I still not sure how to implement the cellEditTemplate. Do you have example that I can take a look at?

    I have one more question, my aggregate result, at the footer of the grid, doesn't always update the value automatically once I change value in other data columns that would effect the result of the aggregate result. If I crate a new row in my grid and change a value for a data columns, and then click on other columns, the aggregate result won't update, unless I have to hit the enter button. Is there ways I can change the behavior of the aggregate result so that I can update the value everytime I change the value in other data columns?

      Thanks
Back to Top