Call the expandGrid function in onclientclick event of button.
function expandGrid()
{
var grid = igtbl_getGridById('<%=UltraWebGrid1.ClientID%>');
expand(grid);
}
function expand(grid)
{
var rowsLength = grid.Rows.length;
for (var i = 0; i < rowsLength; i++)
{
var rowObj = grid.Rows.getRow(i);
if(rowObj.ChildRowsCount != 0)
{
rowObj.setExpanded(true);
expand(rowObj);
}
else
{
break;
}
}
}
Showing posts with label Infragistics. Show all posts
Showing posts with label Infragistics. Show all posts
Monday, February 8, 2010
Format Infragistics Grid column for Currency and Export to Excel with same format
To Format the Hierarchical grid's column from integer to currency, below code can be used.
protected void UltraGrid1_InitializeLayout(object sender, LayoutEventArgs e)
{
UltraGrid1.DisplayLayout.Bands[0].Columns[10].Format = "$ #####0.00";
}
If we export the grid to Excel using UltraWebGridExcelExporter, that column will be integer only. To get in currency format use below code.
In Page_Load add CellExported event like below.
this.UltraWebGridExcelExporter1.CellExported += new Infragistics.WebUI.UltraWebGrid.ExcelExport.CellExportedEventHandler(UltraWebGridExcelExporter1_CellExported);
Code for CellExported event will be like below.
void UltraWebGridExcelExporter1_CellExported(object sender, Infragistics.WebUI.UltraWebGrid.ExcelExport.CellExportedEventArgs e)
{
if (e.GridColumn.Format == "$ #####0.00")
{ e.CurrentWorksheet.Rows[e.CurrentRowIndex].Cells[e.CurrentColumnIndex].CellFormat.FormatString = "$ #####0.00";
}
}
protected void UltraGrid1_InitializeLayout(object sender, LayoutEventArgs e)
{
UltraGrid1.DisplayLayout.Bands[0].Columns[10].Format = "$ #####0.00";
}
If we export the grid to Excel using UltraWebGridExcelExporter, that column will be integer only. To get in currency format use below code.
In Page_Load add CellExported event like below.
this.UltraWebGridExcelExporter1.CellExported += new Infragistics.WebUI.UltraWebGrid.ExcelExport.CellExportedEventHandler(UltraWebGridExcelExporter1_CellExported);
Code for CellExported event will be like below.
void UltraWebGridExcelExporter1_CellExported(object sender, Infragistics.WebUI.UltraWebGrid.ExcelExport.CellExportedEventArgs e)
{
if (e.GridColumn.Format == "$ #####0.00")
{ e.CurrentWorksheet.Rows[e.CurrentRowIndex].Cells[e.CurrentColumnIndex].CellFormat.FormatString = "$ #####0.00";
}
}
Subscribe to:
Posts (Atom)
