Skip to content

DevExpress-Examples/asp-net-mvc-grid-export-colored-grid-in-wysiwyg-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grid View for MVC - How to export a colored grid in WYSIWYG export mode

This example shows how to color the exported grid when WYSIWYG export mode is used.

Export colored grid

The grid does not export cell styles applied in the HtmlDataCellPrepared event.

To color the exported grid in WYSIWYG export mode, handle the GridViewSettings.SettingsExport.RenderBrick event.

settings.SettingsExport.RenderBrick = (sender, e) => {
    if(e.RowType != GridViewRowType.Data)
        return;
    if((e.Column as GridViewDataColumn).FieldName == "UnitPrice" && e.RowType != GridViewRowType.Header) {
        if(Convert.ToInt32(e.TextValue) > 15)
            e.BrickStyle.BackColor = System.Drawing.Color.Yellow;
        else
            e.BrickStyle.BackColor = System.Drawing.Color.Green;
    }
};

Note
Starting from v15.2, the grid maintains conditional formatting styles in the exported document. You can use the GridViewSettings.FormatConditions rules to define conditional formatting in browse mode and keep the applied appearance in the exported document.

Files to Review

Documentation

Technical Demos

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)