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

Styling ReadOnly column

7 Answers 212 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Riia
Top achievements
Rank 1
Riia asked on 09 Dec 2010, 01:24 PM
Hi,

I tried to search but could not find documentation about this so could you please tell how to style readonly columns?
It seems that the column can be set readonly with IsReadOnly (or with IsReadOnlyBinding at column level). However, I didn't see how to attach style to that? I would like to set the background color for readonly columns.

Best Regards,
Riia

7 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 09 Dec 2010, 05:03 PM
Hi Riia,

 
Since the GridViewColumns are not visual objects you cannot create a style targeted at GridViewColumn.
However when your are using IsReadOnlyBinding, you may return desired appearance on a GridViewCell level, you may take a look at the following forum thread. 

You can also check the CellStyleSelector - it applies a different style depending on a value of a property in your business object - probably this will help in your case.

Hope this helps!

Regards,
Vanya Pavlova
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Riia
Top achievements
Rank 1
answered on 10 Dec 2010, 01:29 PM
Hi,

Thank you for the answer. However, I wasn’t able to find the answer from the referenced thread and unfortunately I don’t believe that CellStyleSelector helps in this case, because there is no such property in our business object that would tell if the column/cell should be read only.

Maybe my first question was a bit unclear. We can make the column function as read only just fine, but the correct way for styling it is not known to us. So, the point of the question was how to style the read only columns/cells to appear different from other columns/cells?

We have a custom theme and it includes a cell style. There are VisualStates for Enabled and Disabled in the GridViewCell but there is no such state for Read only. Is there some other way to reference the read only state of the cell from the cell style or how should we define background color for read only cells in our theme?

Best regards,
Riia
0
Vanya Pavlova
Telerik team
answered on 10 Dec 2010, 06:09 PM
Hi Riia,

 
From the previous referenced thread I just wanted to focus your attention to the boolean IsReadOnlyBinding property, which can be set on a grid level or on a column level. Actually this property determines whether or not the GridViewCell can go into edit mode or not. If you bind this property to a property value of the underlying business object you can return the corresponding GridViewCell style whether it is either true or false. In this case you operate on the raw data. Internally the GridViewCell does not expose IsReadOnly property. As far as I can understand such property is missing from your business object or any relevant condition so you do not need to use IsReadOnlyBinding, just check if IsReadOnly property of this column is set to true return the corresponding style that will be applied to all GridViewCells in this column.


I hope that it is much more clear now, but if we are missing something - please give us more details and examples from your project.

Kind regards,
Vanya Pavlova
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Riia
Top achievements
Rank 1
answered on 21 Dec 2010, 01:52 PM
Hi,

Thank you for your reply. Just wanted to tell you that we managed to change the  background color using CellStyleSelector. However, it didn't work well if row selection was used, read-only background color was on top of the selected row color. This is probably because we have to dynamically change SelectionUnit between FullRow and Cell (discussed here Cell Selection & Row Selection). So we decided to change only read-only text color and it works well now.

Thank you for your help!

Best regards,
Riia
0
Riia
Top achievements
Rank 1
answered on 18 Nov 2011, 06:04 AM
Hi again,

We had another requirement to set different background color for one column. This can be achieved by setting special Style for GridViewCell. However we have the same problem as I described in my last post; the background color stays on top even when the row is selected (SelectionUnit FullRow) causing the effect that the selected row is "cut", the selected color is visible before that column and after but not for that column with special GridViewCell style.

Could you please tell if this is by design or is there a way to set background color for certain column so that the selected row color appears on top of that?

Best regards,
Riia
0
Vanya Pavlova
Telerik team
answered on 18 Nov 2011, 08:51 AM
Hello Riia,

 
You should use a color, which allows transparency to achieve your goal.
Furthermore you may also use the Background property of the column, instead of defining cell style. 
Would you please give it a try and let me know how it goes? 



Kind regards,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Riia
Top achievements
Rank 1
answered on 21 Nov 2011, 11:58 AM
Hi Vanya,

thank you for your quick reply! We managed to achieve what we wanted with a color, which allows transparency, thanks!
We could have used the column Background property but decided to use cell style, to allow other stylings for that special column in the future.

Best regards,
Riia
Tags
GridView
Asked by
Riia
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Riia
Top achievements
Rank 1
Share this question
or