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

Changin cell style in telerik > 2020.1.115.45

4 Answers 75 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Gert
Top achievements
Rank 1
Gert asked on 19 Feb 2020, 01:03 PM

Hi,

in 2018.2.515.45 version of telerik RadGridView I did:

var col = new GridViewDataColumn() { DataMemberBinding = new Binding(item.Name), Header = header };
col.CellStyle = new Style();
col.CellStyle.Setters.Add(new Setter(GridViewCell.FontWeightProperty, FontWeights.Bold));
MyRadGridView.Columns.Add(col);

 

to set the font of a certain column to bold. Now, after update to 2020.1.115.45 version this is not working any more. The content of this column is invisible.

I tried this:

col.CellStyle = new Style() { TargetType = typeof(GridViewCell) };

but no changes.

 

How can I add a setter to the style in new version?

BR Gert

 

 

 

4 Answers, 1 is accepted

Sort by
0
Sia
Telerik team
answered on 24 Feb 2020, 12:12 PM

Hello,

I have tested your scenario on my end with our Office Black theme and it looks like it works as expected. Can you please send us a sample project showing your setup?

If this is not possible please let us know which is the theme and the theming mechanism you use in your application (StyleManager or implicit themes).

As you are saying that the content is invisible, I would suggest that you are using StyleManager, but with the upgrade the binaries became NoXAML (which requires implicit styling) which will lead to disappearing of the cells when using a custom style without basing it on ours (GridViewCellStyle in your case). Can you check the binaries as well?

Thank you for your cooperation.
Sia
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Gert
Top achievements
Rank 1
answered on 24 Feb 2020, 03:50 PM

Hi Sia,

we are using implicit styles with NoXAML dll approach and theme = "Office2016".

I try to set the style in the DataContextChanged event of the hosting window, wich was always working:

foreach (var item in dc.Data.First().GetType().GetProperties().Where(Q => Q.CustomAttributes.Any(q => q.AttributeType.Name == "MainCol" || q.AttributeType.Name == "VisibleCol")))
{
    var atr = item.CustomAttributes.FirstOrDefault();
    string header = dc.GetLocalizationByName(atr.ConstructorArguments.First().Value.ToString());
    var col = new GridViewDataColumn() { DataMemberBinding = new Binding(item.Name), Header = header };
    if (atr.AttributeType.Name == "MainCol")
    {
        col.CellStyle = new Style();
        col.CellStyle.Setters.Add(new Setter(GridViewCell.FontWeightProperty, FontWeights.Bold));
    }
    LOVGrid.Columns.Add(col);
}

pic MainColumn

Thanks for helping me!
Gert

 

 

 

0
Accepted
Sia
Telerik team
answered on 25 Feb 2020, 04:03 PM

Hello Gert,

I have reviewed again the code that you have sent and I do not see basing your style on the default one. This is very important because otherwise GridView cells lost their template. That is why the content of the column is invisible. Please check the attached project. This is where I base the style on ours:

Style newStyle = new Style(baseStyle.TargetType, baseStyle);

If it does not help, please modify the project in a way I can see your exact scenario.

Regards,
Sia
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Gert
Top achievements
Rank 1
answered on 26 Feb 2020, 12:19 PM

Hi Sia,

the line

Style baseStyle = Application.Current.Resources["GridViewCellStyle"] as Style;

was the missing hint.

 

Now it is working as expected, thank you very much!!

BR Gert

 

 

 

Tags
General Discussions
Asked by
Gert
Top achievements
Rank 1
Answers by
Sia
Telerik team
Gert
Top achievements
Rank 1
Share this question
or