Is there a setting somewhere that will auto format the width of a column? I am exporting out a ton of grids and I would really like to think that I would not have to set each column's width manually.
Hello Ryan,
Thank you for posting in our community!
The igGrid has default value for the column widths. It is calculated as the whole grid width is divided by the number of the columns. These default values could be changed when the grid is initialized. I have added a code snippet which demonstrates how custom widths could be set for your reference:
$("#grid1").igGrid({
primaryKey: "ProductID",
autoCommit: true,
columns: [
{ headerText: "Product ID", key: "ProductID", dataType: "number", width: "30px" },
{ headerText: "Product Name", key: "Name", dataType: "string", width: "120px" },
{ headerText: "Product Number", key: "ProductNumber", dataType: "string", width: "100px" },
],
When exporting is used it is expected the column widths values to be maintained.
If you need more details could you please provide me additional information for your scenario? What are the grids exported to? Have you set default values for the column widths when the grids are initialized?
Looking forwards to hearing from you.
But can we have any event of the Excel Export API so that we can set the width there such as ,
$.ig.GridExcelExporter.exportGrid($("#TreeGrid"),{ fileName: "XYZ", worksheetName: XYZ Report', // columnsToSkip: ["ProductID", "Supplier"] });
here any event through which we can set the width, and formatting of the Columns in the Exported File
As also Iam facing one more problem in the exported File
Ah, thanks for that bit of information. We are not using the width setting on the igGrids as we are sizing them via the div container so when they are exporting to excel via the Excel library control, they get exported with no width settings. I know we can set the setting via the export method in the sample code below.
curreWorksheet.Columns[0].CellFormat.Alignment = HorizontalCellAlignment.Center; curreWorksheet.Columns[0].Width = 1000;
I was just hoping there was a quick way to set each column to an "auto width" but I guess there isn't. HA! Thanks.