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

gridcell conditional formatting problem..

4 Answers 37 Views
GridView
This is a migrated thread and some comments may be shown as answers.
serkanp
Top achievements
Rank 1
serkanp asked on 26 Apr 2011, 02:34 PM
hi i have a new problem :)           

var startDate = ScheduleGrid.ChildrenOfType<GridViewCell>().Where(c => c.Column.UniqueName == "startDate");
var s1 = startDate.Where(c => (Convert.ToDateTime(c.Value)).Date <= DateTime.Now.Date).ToList();
s1.ForEach(c => c.Background = new SolidColorBrush(Colors.Green));
s1.ForEach(c => c.Foreground = new SolidColorBrush(Colors.White));
 
var endDate = ScheduleGrid.ChildrenOfType<GridViewCell>().Where(c => c.Column.UniqueName == "endDate");
var s2 = endDate.Where(c => (Convert.ToDateTime(c.Value)).Date >= DateTime.Now.Date).ToList();
s2.ForEach(c => c.Background = new SolidColorBrush(Colors.Green));
s2.ForEach(c => c.Foreground = new SolidColorBrush(Colors.White));

i am using selecting cells and query them.. find the result, change the back and fore color..

but what i want to do is:
if (today >= startDate) AND (today<=endDate)
change the background to green and foreground to white of each startDate and endDate column
else
change the background to red and foreground to yellow of each startDate and endDate column


how can i do it in a shorter way?

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 26 Apr 2011, 02:40 PM
Hi,

 You should not work with UI elements directly since RadGridView is UI virtual component and during scroll you will get different data with the same rows, cells, etc. 

Please check this demo for more info about conditional formating:
http://demos.telerik.com/silverlight/#GridView/Selectors/StyleSelectors/CellStyleSelector

Best wishes,
Vlad
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
serkanp
Top achievements
Rank 1
answered on 26 Apr 2011, 03:14 PM
hi Vlad, 
ok but i dont understand how i can do my conditional setting regarding your example..  :)))

in your example i couldnt find any information on defining more then 2 column and formatting them.. 

i need a more specific example.. please help.. 


ps:i used RowLoaded event for formatting columns.. so does this mean, when each row loaded, use this settings?




0
serkanp
Top achievements
Rank 1
answered on 26 Apr 2011, 05:09 PM
depending to :
http://www.telerik.com/help/silverlight/gridview-how-to-customize-ui-programmatically.html

i used those methods.. 
i want to use linq and lambda to customize my grid.. why dont you advise this operation?
i tried many things on your suggestion but still i cant get what i want.. 

but with programatically customization, i get a little success.. 
but still i cant combine 2 cell's values and format them at the same time.. 

vlad, i know you are too busy, maybe you found my question very stupid.. but this is not a home project.. :( i have a huge business.. i am controlling 1.000 device with 1 managment application.. while using telerik winforms grid , i used paint event.. and it was working perfect.. 

i attached 2 screenshots.. winforms is the current working application.. i  have different conditional formatting.. 
and silverlight.jpg is the new one.. 

i just want to control everything programatically, not using xaml.... sorry i dont understand that example.. 
so please show me an example.. :) i need more specific example.. i will add more conditions.. not 1-2.. so i must make it programatically.. 

thanks
Serkan
0
Vlad
Telerik team
answered on 27 Apr 2011, 06:55 AM
Hello,

 You do not need to declare the selectors in XAML - you can create them programmatically. As I posted in my previous reply in WPF/Silverlight world most or item controls like grid, lists, etc are virtual and you cannot access their rows, cells, etc. - that is why you need to use Style and Template selectors. 

Greetings,
Vlad
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
GridView
Asked by
serkanp
Top achievements
Rank 1
Answers by
Vlad
Telerik team
serkanp
Top achievements
Rank 1
Share this question
or