Display a string for a boolean type column.

Hi,

I have a grid that has a property of Boolean type, as I can show it in "Active", "Inactive" according to whether it is true or false, besides that I need
export it to excel passing the values ​​of "Active" and "Inactive"

Stay tuned.

Regards!

3 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team August 20, 2018 08:49 AM UTC

Hi Corazon, 

Thanks for using Syncfusion support.  

Based on your query we understand that you need to export the Grid records to excel with different text for Boolean column instead of True / False. So, we suggest you to achieve your requirement using ServerExcelQueryInfo event of grid while exporting.  

Refer the below code example 

[C#] 
 
public ActionResult ExportToExcel(string GridModel) 
        { 
            ExcelExport exp = new ExcelExport(); 
            var DataSource = order.ToList(); 
            GridProperties obj = (GridProperties)Syncfusion.JavaScript.Utils.DeserializeToModel(typeof(GridProperties), GridModel); 
            obj.ServerExcelQueryCellInfo = QueryCellInfo; 
            GridExcelExport excelExp = new GridExcelExport(); 
            excelExp.FileName = "Export.xlsx"; excelExp.Excelversion = ExcelVersion.Excel2010; 
            excelExp.Theme = "flat-saffron"; 
            return exp.Export(obj, DataSource, excelExp); 
        } 
 
 
        public void QueryCellInfo(object currentCell) 
        { 
            IRange range = (IRange)currentCell; 
            if (range.Column == 5) 
            { 
 
                if(range.Value == "TRUE") 
                    range.Value = "Active"; 
                else                 
                    range.Value = "InActive"; 
                 
            } 
 
        } 

For your convenience we have prepared a sample which can be downloaded from below link 


Refer our UG documentation on server side exporting events. 

 
Regards, 
Prasanna Kumar N.S.V 



CC Corazon Cruz Sanchez August 20, 2018 05:02 PM UTC

Hi Prasanna,

My problem was solved thank you very much.

Regards!



PK Prasanna Kumar Viswanathan Syncfusion Team August 21, 2018 04:55 AM UTC

Hi Corazon, 

We are happy to hear that your issue has been solved. 

Please let us know if you need any further assistance. 

Regards, 
Prasanna Kumar N.S.V 


Loader.
Up arrow icon