Welcome Guest Search | Active Topics | Sign In | Register

Grid Cell Color Options
oeoeoe
Posted: Tuesday, November 2, 2010 4:51:54 AM
Rank: Member
Groups: Member

Joined: 10/13/2010
Posts: 11
Hey

For creating a Workflow application it would be really nice to get an event or virtual function on Render whicht asks which color a cell should have (for Current Cell Data)

Thx
eo_support
Posted: Tuesday, November 2, 2010 9:52:43 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

You can do that in the current version by calling this function:

http://doc.essentialobjects.com/library/1/jsdoc.public.gridcell.overridestyle.aspx

However this is not an event. So you must call it explicitly.

Thanks!
oeoeoe
Posted: Wednesday, November 3, 2010 7:03:21 AM
Rank: Member
Groups: Member

Joined: 10/13/2010
Posts: 11
Hi

This doesn't work for me... I have to do it server side.

I need to style every Cell Background itself and for this I need Cell Value

People Day 1 Day2 Day3
Person1 red green yellow
Person2 green yellow red

I just found out I can set Column.CellStyle.BackColor but this acts for the whole column.

Thx
eo_support
Posted: Wednesday, November 3, 2010 9:28:00 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

You can use this property on the server side:

http://doc.essentialobjects.com/library/1/eo.web.gridcolumn.stylefield.aspx

Thanks
oeoeoe
Posted: Wednesday, November 3, 2010 10:55:29 AM
Rank: Member
Groups: Member

Joined: 10/13/2010
Posts: 11
Hi,

I don't know at all how I could use this in my app (The decision which colors isn't that easy...).

I think I need to render the Cell myself, isn't there an event or something like DatePicker DayRender?

I read a lot in this forum and found a lot of people which seem to have the same problem...

Thx
eo_support
Posted: Wednesday, November 3, 2010 11:07:06 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

You don't do it the same way as DatePicker's DayRender. You usually prepare a DataTable first. For each data column you will have an additional column that will be used for styles. So for example, if your data has a single column like:

Code:
Column Name: Grade
Row1:        Good
Row2:        Bad
Row3:        Very Bad


If you want to display green for "Good", yellow for "Bad" and red for "Very Bad", then you will need to add an additional column into your DataTable:

Code:
Column Name: Grade   Style
Row1:        Good    good_grade_style
Row2:        Bad     bad_grade_style
Row3:        Very    Bad very_bad_grade_style


Here "good_grade_style", "bad_grade_style" and "very_bad_grade_style" are CSS classes that you must define in your CSS file. You would then set the columns' DataField to "Grade" and StyleField to "Style". At runtime, the Grid will apply each row's style to each cell.

Note column "Style" does not exist in your physical database. It's just an additional column that you create in the memory. You can do it with database view, or an additional calculated column in your SELECT expression, or an additional column in DataTable object.

Thanks
oeoeoe
Posted: Wednesday, November 3, 2010 11:35:00 AM
Rank: Member
Groups: Member

Joined: 10/13/2010
Posts: 11
Hi

Ok I got It how I "could" do it, but the colors for Fore-Color and Back-Color are Saved on SQL-Server (User can Edit...), so i would have to generate a CSS class foreach Cell by runtime which sounds (...) for me...

Thx for your help but I think I have to build my own grid if there won't come a new feature (like DatePicker DayRender)...
eo_support
Posted: Wednesday, November 3, 2010 11:43:39 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

In that case you can always format each cell's Html directly. For example, instead of setting the cell value as "Good", you would format a string based on your data base value as "<div style='color:green'>Good</div>" and give the Grid that value.

Thanks
Jack.Wu
Posted: Thursday, January 27, 2011 3:12:53 AM
Rank: Advanced Member
Groups: Member

Joined: 5/22/2009
Posts: 33
Hello Sir,

Just ask that if I put "<div style='color:green'>Good</div>" in the Grid Cell' value, when I enter the edit mode, what will be displayed in the cell editor? Is it only display "Good" to be edited or it will display "<div style='color:green'>Good</div>" for edit? Thank you.
eo_support
Posted: Thursday, January 27, 2011 9:01:25 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

For TextBoxColumn, it will display exactly what you have put into the cell. If you want to change that behavior, you will need to use a CustomColumn to implement any additional logic yourself.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.