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

Cell theme for read-only columns

1 Answer 30 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rachel
Top achievements
Rank 2
Rachel asked on 17 Jul 2010, 05:54 PM
I want to have my grid them my cells in read-only columns to use a different foreground color.  I was able to set this up in my theme using the IsReadOnly property of GridCellElement:

<XmlPropertySettingGroup>
    <PropertySettings>
        <XmlPropertySetting Property="Telerik.WinControls.VisualElement.ForeColor" Value="160, 160, 160" />
    </PropertySettings>
    <Selectors>
        <XmlClassSelector ElementClass="DataCell" AutoUnapply="False">
            <Condition xsi:type="XmlSimpleCondition" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <Setting Property="Telerik.WinControls.UI.GridCellElement.IsReadOnly" Value="True" />
            </Condition>
        </XmlClassSelector>
    </Selectors>
</XmlPropertySettingGroup>

Then in the view cell formatting event, I added code to set each cell's IsReadOnly to match that of its column:

e.CellElement.IsReadOnly = e.CellElement.ColumnInfo.ReadOnly;

All of this works fine, but I get warnings that GridCellElement.IsReadOnly is obsolete.  Is there another property I should be using to set this up in my theme?  IsReadOnly seemed the best option in the visual style builder.

Thanks,
Rachel

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 20 Jul 2010, 06:47 AM
Hi Rachel,

Thank you for your feedback. This property was never synchronized internally in RadGridView and we did not think that someone is using it. That's why we decided to make it obsolete. However, your case looks interesting and we may reconsider our decision for our upcoming service pack.

Right now you have the following options:

1. You can define your own dependency property and use custom cell elements. Here is a sample:

public class MyDataCell : GridDataCellElement
{
    public static RadProperty ReadOnlyProperty = RadProperty.Register(
       "ReadOnly", typeof(bool), typeof(GridCellElement), new RadElementPropertyMetadata(
           false, ElementPropertyOptions.AffectsDisplay));
 
    protected override Type ThemeEffectiveType
    {
        get { return typeof(GridDataCellElement); }
    }
 
    public MyDataCell(GridViewColumn column, GridRowElement row)
        : base(column, row)
    {           
    }
 
    protected override void UpdateInfoCore()
    {
        base.UpdateInfoCore();
        SetValue(ReadOnlyProperty, this.ColumnInfo.ReadOnly);
    }
}

2. The second option is replacing the IsReadOnly property with the Enabled property. In this case you should set the UseDefaultDisabledPaint property to false.

I hope this helps. If you have further questions, I will be glad to answer.

 

Best wishes,
Jack
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
Rachel
Top achievements
Rank 2
Answers by
Jack
Telerik team
Share this question
or