Save Conditional Formatting

9 posts, 0 answers
  1. Paul
    Paul avatar
    35 posts
    Member since:
    Aug 2015

    Posted 14 Jun 2016 Link to this post

    I've read several reasons why it's not built into the SaveLayout, but I still would like a way to save Conditional Formatting. How can I achieve this?
  2. Dimitar
    Admin
    Dimitar avatar
    1649 posts

    Posted 15 Jun 2016 Link to this post

    Hi Paul,

    Thank you for writing.

    The conditional formatting is saved when the layout is saved, this should work out of the box. 

    Let me know if I can assist you further.

    Regards,
    Dimitar
    Telerik
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. Victor
    Victor avatar
    19 posts
    Member since:
    Aug 2016

    Posted 10 Apr Link to this post

    Hi,

    If you want to save your gridview in the Property Builder, there is an option to exclude everythnig except the conditional formatting.

    Is this (saving only the cond. format xml) also possible programmatically : I would like to have one company wide Cond. Form. for all the users. The rest of the layout of the grids are pure individual.

     

    Hope to hearing from you soon

    Victor

  4. Hristo
    Admin
    Hristo avatar
    889 posts

    Posted 11 Apr Link to this post

    Hello Victor,

    Thank you for writing.

    The conditional formatting objects are serialized and this is the default behavior. It can be customized by accessing the SerializationMetadata collection: http://docs.telerik.com/devtools/winforms/gridview/save-and-load-layout/advanced.

    In case you need further assistance please provide me with more details about your actual scenario.

    I hope this helps.

    Regards,
    Hristo
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Victor
    Victor avatar
    19 posts
    Member since:
    Aug 2016

    Posted 18 Apr in reply to Hristo Link to this post

    Hello Hristo,

    I the attached picture you can see what I am trying to achieve : Personal settings per user per radgridview (that works fine), but a corporate standard XML file containing the settings for the conditional formatting.

    I have looked at the documentation but it does not states the metadata keywords needed for the conditonal formats. Can you supply me with these?

    And a second question on de save/loadXML

    If a grid changes (column added e.g.), the saved XML does not contain this column. That is logical. Is there a way without deleting the old XML (with all the usersettings) first to add this column in de xml file?

     

    hope to hear from you soon

    Kind regards

    Victor

  6. Dimitar
    Admin
    Dimitar avatar
    1649 posts

    Posted 18 Apr Link to this post

    Hello Victor,

    Thank you for writing back.

    Here are the required properties for saving the conditional formatting:
    private void radButton1_Click(object sender, EventArgs e)
    {
        radGridView1.XmlSerializationInfo.DisregardOriginalSerializationVisibility = true;
        radGridView1.XmlSerializationInfo.SerializationMetadata.Clear();
        radGridView1.XmlSerializationInfo.SerializeDefaultValues = true;
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(RadGridView), "MasterTemplate", DesignerSerializationVisibilityAttribute.Content);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(GridViewTemplate), "Columns", DesignerSerializationVisibilityAttribute.Content);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(GridViewDataColumn), "Name", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(GridViewDataColumn), "HeaderText", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(GridViewDataColumn), "FieldName", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(GridViewDataColumn), "ConditionalFormattingObjectList", new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content));
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(ConditionalFormattingObject), "Name", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(ConditionalFormattingObject), "ConditionType", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(ConditionalFormattingObject), "TValue1", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(ConditionalFormattingObject), "TValue2", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(ConditionalFormattingObject), "RowBackColor", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(ConditionalFormattingObject), "RowForeColor", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(ConditionalFormattingObject), "CellForeColor", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(ConditionalFormattingObject), "CellBackColor", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(ConditionalFormattingObject), "CellFont", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(ConditionalFormattingObject), "RowFont", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(ConditionalFormattingObject), "ApplyToRow", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(ConditionalFormattingObject), "ApplyOnSelectedRows", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.SaveLayout(@"D:\Formatting.xml");
     
    }

    If you want to add new columns you will need to add them after the layout is initially loaded (to preserve the previous layout). Then you can save it again. In general, we do not have a mechanism that allows using the same layout file with different versions of the program and this should be handled manually. 

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  7. Victor
    Victor avatar
    19 posts
    Member since:
    Aug 2016

    Posted 18 Apr in reply to Dimitar Link to this post

    Hi Dimitar, this indeed helps a lot.

    I am going to give it a try.

    Kind regards 

    Victor

  8. Victor
    Victor avatar
    19 posts
    Member since:
    Aug 2016

    Posted 18 Apr in reply to Victor Link to this post

    Hello Dimitar,

    Another question : If I load the just saved xml, the colums still go back in their previous position with their previous width.

    Isn't it possible just to load the conditional formats?

    KG

    Vic

  9. Dimitar
    Admin
    Dimitar avatar
    1649 posts

    Posted 19 Apr Link to this post

    Hi Victor,

    Since each column has a property that contains all ConditionalFormattingObjects there is no way to save only these objects. They do not keep a reference to the column.

    Should you have any other questions do not hesitate to ask. 

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top