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

display result in expression under condition

4 Answers 89 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Johnny
Top achievements
Rank 1
Johnny asked on 16 Feb 2012, 04:11 AM
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.

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 16 Feb 2012, 08:19 AM
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 >>
0
Johnny
Top achievements
Rank 1
answered on 17 Feb 2012, 02:22 AM
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
0
Dimitrina
Telerik team
answered on 17 Feb 2012, 03:38 PM
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 >>
0
Johnny
Top achievements
Rank 1
answered on 22 Feb 2012, 02:14 AM
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
Tags
GridView
Asked by
Johnny
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Johnny
Top achievements
Rank 1
Share this question
or