This example shows how to color the exported grid when WYSIWYG export mode is used.
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.
- HomeController.cs (VB: HomeController.vb)
- Model.cs (VB: Model.vb)
- GridViewPartialProducts.cshtml
- Index.cshtml
- Grid View for MVC - How to export a colored grid in Data Aware export mode
- Grid View for Web Forms - How to export a colored grid in Data Aware export mode
- Grid View for Web Forms - How to export a colored grid in WYSIWYG export mode
(you will be redirected to DevExpress.com to submit your response)