protected void pgridDetalle_ItemCommand(object sender, Telerik.Web.UI.PivotGridCommandEventArgs e) { if (e.CommandName == "ExpandCollapse") { PivotGridColumnHeaderCell cell = e.Item.Cells[0] as Telerik.Web.UI.PivotGridColumnHeaderCell; if (cell.Expanded) { cell.CssClass = "Contraido"; } else { cell.CssClass = "Expandido"; } } }
protected void grdPresupuesto_CellDataBound(object sender, Telerik.Web.UI.PivotGridCellDataBoundEventArgs e) { //&month& patterns is added in the DataFormatString, so it could be catched and parsed to month name if (e.Cell is PivotGridColumnHeaderCell) { int month = 0; string strMes = ""; PivotGridColumnHeaderCell cell = e.Cell as PivotGridColumnHeaderCell; strMes = cell.Text.ToString(); if (strMes.Length > 0 && strMes.Length < 3) { string cellValue = strMes; if (int.TryParse(cellValue, out month)) { cell.Text = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(int.Parse(cellValue)); } } } }
protected void gsReporteVentas_Item_CellDataBound(object sender, PivotGridCellDataBoundEventArgs e) { int importe = 0; try { if (e.Cell is PivotGridDataCell) { PivotGridDataCell cell = e.Cell as PivotGridDataCell; //color all data cells if (cell.CellType == PivotGridDataCellType.DataCell) { importe = 0; cell.Font.Bold = false; cell.BackColor = Color.White; cell.HorizontalAlign = HorizontalAlign.Right; if (cell.ParentColumnIndexes[2].ToString() == "Margen_2017_c") { cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe <= 30) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } else if (importe > 30 & importe <= 50) { cell.BackColor = Color.Yellow; cell.ForeColor = Color.Black; } else if (importe > 50) { cell.BackColor = Color.LawnGreen; cell.ForeColor = Color.Black; } } if (cell.ParentColumnIndexes[2].ToString() == "Margen_2016_c") { //cell.BackColor = Color.Yellow; //cell.Font.Italic = true; cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe <= 30) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } else if (importe > 30 & importe <= 50) { cell.BackColor = Color.Yellow; cell.ForeColor = Color.Black; } else if (importe > 50) { cell.BackColor = Color.LawnGreen; cell.ForeColor = Color.Black; } } if (cell.ParentColumnIndexes[2].ToString() == "VPU_2016_c") { cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } else { //cell.BackColor = Color.Lavender; cell.ForeColor = Color.Black; } } if (cell.ParentColumnIndexes[2].ToString() == "VPU_PPTO_c") { cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } else { //cell.BackColor = Color.Lavender; cell.ForeColor = Color.Black; } } if (cell.ParentColumnIndexes[2].ToString() == "VMg17_16_c") { cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } else { //cell.BackColor = Color.Lavender; cell.ForeColor = Color.Black; } } } //Black - color the Sub totals rows cells if (cell.CellType == PivotGridDataCellType.RowTotalDataCell) { cell.BackColor = Color.LightSteelBlue; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; if (cell.ParentColumnIndexes[2].ToString() == "Margen_2017_c") { importe = Convert.ToInt32(cell.DataItem); if (importe <= 30) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } else if (importe > 30 & importe <= 50) { cell.BackColor = Color.Yellow; cell.ForeColor = Color.Black; } else if (importe > 50) { cell.BackColor = Color.LawnGreen; cell.ForeColor = Color.Black; } } if (cell.ParentColumnIndexes[2].ToString() == "Margen_2016_c") { importe = Convert.ToInt32(cell.DataItem); if (importe <= 30) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } else if (importe > 30 & importe <= 50) { cell.BackColor = Color.Yellow; cell.ForeColor = Color.Black; } else if (importe > 50) { cell.BackColor = Color.LawnGreen; cell.ForeColor = Color.Black; } } if (cell.ParentColumnIndexes[2].ToString() == "VPU_2016_c") { importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } } if (cell.ParentColumnIndexes[2].ToString() == "VPU_PPTO_c") { importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } } if (cell.ParentColumnIndexes[2].ToString() == "VMg17_16_c") { importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } } } //Yellow - color the column/row / grand total rows if (cell.CellType == PivotGridDataCellType.RowGrandTotalDataCell) { cell.BackColor = Color.Silver; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; if (cell.ParentColumnIndexes[2].ToString() == "Margen_2017_c") { importe = Convert.ToInt32(cell.DataItem); if (importe <= 30) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } else if (importe > 30 & importe <= 50) { cell.BackColor = Color.Yellow; cell.ForeColor = Color.Black; } else if (importe > 50) { cell.BackColor = Color.LawnGreen; cell.ForeColor = Color.Black; } } if (cell.ParentColumnIndexes[2].ToString() == "Margen_2016_c") { importe = Convert.ToInt32(cell.DataItem); if (importe <= 30) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } else if (importe > 30 & importe <= 50) { cell.BackColor = Color.Yellow; cell.ForeColor = Color.Black; } else if (importe > 50) { cell.BackColor = Color.LawnGreen; cell.ForeColor = Color.Black; } } if (cell.ParentColumnIndexes[2].ToString() == "VPU_2016_c") { importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } } if (cell.ParentColumnIndexes[2].ToString() == "VPU_PPTO_c") { importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } } if (cell.ParentColumnIndexes[2].ToString() == "VMg17_16_c") { importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } } } //Red - color the totals Column cells if (cell.CellType == PivotGridDataCellType.ColumnTotalDataCell) { cell.BackColor = Color.LightGray; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; if (cell.ParentColumnIndexes[1].ToString() == "2017 Margen_2017_c") { importe = Convert.ToInt32(cell.DataItem); if (importe <= 30) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } else if (importe > 30 & importe <= 50) { cell.BackColor = Color.Yellow; cell.ForeColor = Color.Black; } else if (importe > 50) { cell.BackColor = Color.LawnGreen; cell.ForeColor = Color.Black; } } if (cell.ParentColumnIndexes[1].ToString() == "2017 Margen_2016_c") { importe = Convert.ToInt32(cell.DataItem); if (importe <= 30) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } else if (importe > 30 & importe <= 50) { cell.BackColor = Color.Yellow; cell.ForeColor = Color.Black; } else if (importe > 50) { cell.BackColor = Color.LawnGreen; cell.ForeColor = Color.Black; } } if (cell.ParentColumnIndexes[1].ToString() == "2017 VPU_2016_c") { importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } } if (cell.ParentColumnIndexes[1].ToString() == "2017 VPU_PPTO_c") { importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } } if (cell.ParentColumnIndexes[1].ToString() == "2017 VMg17_16_c") { importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } } } //Orange - color SubTotales column cells if (cell.CellType == PivotGridDataCellType.RowAndColumnTotal) { cell.BackColor = Color.LightSteelBlue; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; if (cell.ParentColumnIndexes[1].ToString() == "2017 Margen_2017_c") { importe = Convert.ToInt32(cell.DataItem); if (importe <= 30) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } else if (importe > 30 & importe <= 50) { cell.BackColor = Color.Yellow; cell.ForeColor = Color.Black; } else if (importe > 50) { cell.BackColor = Color.LawnGreen; cell.ForeColor = Color.Black; } } if (cell.ParentColumnIndexes[1].ToString() == "2017 Margen_2016_c") { importe = Convert.ToInt32(cell.DataItem); if (importe <= 30) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } else if (importe > 30 & importe <= 50) { cell.BackColor = Color.Yellow; cell.ForeColor = Color.Black; } else if (importe > 50) { cell.BackColor = Color.LawnGreen; cell.ForeColor = Color.Black; } } if (cell.ParentColumnIndexes[1].ToString() == "2017 VPU_2016_c") { importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } } if (cell.ParentColumnIndexes[1].ToString() == "2017 VPU_PPTO_c") { importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } } if (cell.ParentColumnIndexes[1].ToString() == "2017 VMg17_16_c") { importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } } } // Azul - Color GrandTotal Column if (cell.CellType == PivotGridDataCellType.RowGrandTotalColumnTotal) { cell.BackColor = Color.Silver; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; if (cell.ParentColumnIndexes[1].ToString() == "2017 Margen_2017_c") { importe = Convert.ToInt32(cell.DataItem); if (importe <= 30) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } else if (importe > 30 & importe <= 50) { cell.BackColor = Color.Yellow; cell.ForeColor = Color.Black; } else if (importe > 50) { cell.BackColor = Color.LawnGreen; cell.ForeColor = Color.Black; } } if (cell.ParentColumnIndexes[1].ToString() == "2017 Margen_2016_c") { importe = Convert.ToInt32(cell.DataItem); if (importe <= 30) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } else if (importe > 30 & importe <= 50) { cell.BackColor = Color.Yellow; cell.ForeColor = Color.Black; } else if (importe > 50) { cell.BackColor = Color.LawnGreen; cell.ForeColor = Color.Black; } } if (cell.ParentColumnIndexes[1].ToString() == "2017 VPU_2016_c") { importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } } if (cell.ParentColumnIndexes[1].ToString() == "2017 VPU_PPTO_c") { importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } } if (cell.ParentColumnIndexes[1].ToString() == "2017 VMg17_16_c") { importe = Convert.ToInt32(cell.DataItem); if (importe < 0.00) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } } } //color the column AND row grand total cell else if (cell.CellType == PivotGridDataCellType.RowAndColumnGrandTotal) { cell.BackColor = Color.Blue; cell.Font.Bold = true; } } ////style the row headers based on their level else if (e.Cell is PivotGridRowHeaderCell) { PivotGridRowHeaderCell cell = e.Cell as PivotGridRowHeaderCell; if (cell.ParentIndexes != null && cell.ParentIndexes.Length == 1) { cell.Font.Bold = true; //cell.HorizontalAlign = HorizontalAlign.Center; } else { //cell.Font.Italic = false; } } ////style the column headers based on their level else if (e.Cell is PivotGridColumnHeaderCell) { PivotGridColumnHeaderCell cell = e.Cell as PivotGridColumnHeaderCell; if (cell.ParentIndexes != null) { cell.Font.Bold = false; //cell.HorizontalAlign = HorizontalAlign.; } } } catch (Exception ex) { lblMensaje.Text = ex.Message; lblMensaje.CssClass = "mensajeError"; } //give a color to the various cells cells }
protected void gsReporteVentas_Familia_CellDataBound(object sender, PivotGridCellDataBoundEventArgs e) { try { if (e.Cell is PivotGridDataCell) { PivotGridDataCell cell = e.Cell as PivotGridDataCell; //color all data cells if (cell.CellType == PivotGridDataCellType.DataCell) { int importe = 0; cell.Font.Bold = false; cell.BackColor = Color.Lavender; cell.HorizontalAlign = HorizontalAlign.Right; if (cell.RowIndex == 2 || cell.RowIndex == 7 || cell.RowIndex == 9 || cell.RowIndex == 10 || cell.RowIndex == 13) { cell.BackColor = Color.Silver; } if (cell.ParentColumnIndexes[4].ToString() == "Sum of ImporteMes") { //cell.BackColor = Color.Khaki; //cell.Font.Italic = true; //cell.HorizontalAlign = HorizontalAlign.Right; //if(cell.RowIndex==2) //{ // cell.BackColor = Color.Silver; //} //if (importe <= 30) //{ // cell.BackColor = Color.LightGreen; // cell.ForeColor = Color.Black; //} //else if (importe > 30) //{ // cell.BackColor = Color.Red; // cell.ForeColor = Color.White; //} } //if (cell.ParentColumnIndexes[1].ToString() == "Sum of PorcentajeMes") //{ // cell.BackColor = Color.LightGreen; // //cell.Font.Italic = true; // cell.HorizontalAlign = HorizontalAlign.Center; // //importe = Convert.ToInt32(cell.DataItem); // //if (importe <= 0) // //{ // // cell.BackColor = Color.Tomato; // // cell.ForeColor = Color.White; // //} // //else // //{ // // cell.BackColor = Color.White; // // cell.ForeColor = Color.Black; // //} //} } //color the totals cells else if (cell.CellType == PivotGridDataCellType.ColumnTotalDataCell || cell.CellType == PivotGridDataCellType.RowTotalDataCell) { switch ((cell.Field as PivotGridAggregateField).DataField) { //color the cells showing totals for TotalPrice based on their value case "KgLt": //cell.Field.CellStyle.CssClass = "aggregateCustom1"; cell.BackColor = Color.Silver; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; //if (cell.DataItem != null && cell.DataItem.ToString().Length > 0) //{ // int price = Convert.ToInt32(cell.DataItem); // if (price > 200) // { // cell.BackColor = Color.SteelBlue; // } // else if (price > 500) // { // cell.BackColor = Color.Tomato; // } // else // { // cell.BackColor = Color.Violet; // } //} break; //color the cells showing totals for Quantity based on their value case "KgLtPro": //if (cell.DataItem != null && cell.DataItem.ToString().Length > 0) //{ cell.BackColor = Color.Silver; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; //double quantity = Convert.ToDouble(cell.DataItem); //if (quantity > 200) //{ // cell.BackColor = Color.GreenYellow; //} //else if (quantity > 100) //{ // cell.BackColor = Color.Khaki; //} //else //{ // cell.BackColor = Color.IndianRed; //} //} break; default: cell.BackColor = Color.Silver; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; break; } } //color the column/row grand total cells else if (cell.CellType == PivotGridDataCellType.RowGrandTotalDataCell || cell.CellType == PivotGridDataCellType.ColumnGrandTotalDataCell) { switch ((cell.Field as PivotGridAggregateField).DataField) { case "KgLt": cell.BackColor = Color.Silver; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; int price = Convert.ToInt32(cell.DataItem); //if (price > 100) //{ // cell.BackColor = Color.Orange; //} //else //{ // cell.BackColor = Color.Pink; //} break; case "KgLtPro": double quantity = Convert.ToDouble(cell.DataItem); cell.BackColor = Color.Silver; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; //cell.Field.CellStyle.BackColor = Color.Red; //if (quantity > 20) //{ // cell.BackColor = Color.Red; //} //else //{ // cell.BackColor = Color.Yellow; //} break; default: cell.BackColor = Color.Silver; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; break; } } //color the column AND row grand total cell else if (cell.CellType == PivotGridDataCellType.RowAndColumnGrandTotal) { cell.BackColor = Color.Blue; cell.Font.Bold = true; } } ////style the row headers based on their level else if (e.Cell is PivotGridRowHeaderCell) { PivotGridRowHeaderCell cell = e.Cell as PivotGridRowHeaderCell; if (cell.ParentIndexes != null && cell.ParentIndexes.Length == 1) { cell.Font.Bold = true; //cell.HorizontalAlign = HorizontalAlign.Center; } else { //cell.Font.Italic = false; } } ////style the column headers based on their level else if (e.Cell is PivotGridColumnHeaderCell) { PivotGridColumnHeaderCell cell = e.Cell as PivotGridColumnHeaderCell; if (cell.ParentIndexes != null) { cell.Font.Bold = false; cell.BorderColor = Color.Black; //cell.HorizontalAlign = HorizontalAlign.Center; } } } catch (Exception ex) { lblMensaje.Text = ex.Message; lblMensaje.CssClass = "mensajeError"; } //give a color to the various cells cells }
protected void gsReporteVentas_Zonas_CellDataBound(object sender, PivotGridCellDataBoundEventArgs e) { try { if (e.Cell is PivotGridDataCell) { PivotGridDataCell cell = e.Cell as PivotGridDataCell; cell.Font.Bold = false; cell.BackColor = Color.White; cell.HorizontalAlign = HorizontalAlign.Right; if (cell.CellType == PivotGridDataCellType.DataCell) { cell.Font.Bold = false; cell.BackColor = Color.White; cell.HorizontalAlign = HorizontalAlign.Right; if (cell.ParentColumnIndexes[2].ToString() == "Crecimiento") { //cell.BackColor = Color.Yellow; //cell.Font.Italic = true; cell.HorizontalAlign = HorizontalAlign.Right; decimal porcentaje = Convert.ToDecimal(cell.DataItem); if (porcentaje <= 0) { cell.BackColor = Color.Tomato; cell.ForeColor = Color.White; } } //if (cell.ParentColumnIndexes[1].ToString() == "VariacionPrecio") //{ // //cell.BackColor = Color.Yellow; // //cell.Font.Italic = true; // cell.HorizontalAlign = HorizontalAlign.Right; // int price = Convert.ToInt32(cell.DataItem); // if (price <= 0) // { // cell.BackColor = Color.Tomato; // cell.ForeColor = Color.White; // } // else if (price > 0) // { // cell.BackColor = Color.LawnGreen; // cell.ForeColor = Color.Black; // } //} } //Black - color the Sub totals rows cells if (cell.CellType == PivotGridDataCellType.RowTotalDataCell) { cell.BackColor = Color.PaleGreen; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; switch ((cell.Field as PivotGridAggregateField).DataField) { //color the cells showing totals for TotalPrice based on their value //case "SaldoDolares": // //cell.Field.CellStyle.CssClass = "aggregateCustom1"; // cell.BackColor = Color.Black; // cell.Font.Bold = true; // cell.HorizontalAlign = HorizontalAlign.Right; // break; ////color the cells showing totals for Quantity based on their value //case "KgLtPro": // //if (cell.DataItem != null && cell.DataItem.ToString().Length > 0) // //{ // cell.BackColor = Color.Silver; // cell.Font.Bold = true; // cell.HorizontalAlign = HorizontalAlign.Right; // break; //default: // cell.BackColor = Color.Silver; // cell.Font.Bold = true; // cell.HorizontalAlign = HorizontalAlign.Right; // break; } } //Yellow - color the column/row / grand total rows if (cell.CellType == PivotGridDataCellType.RowGrandTotalDataCell) { cell.BackColor = Color.Silver; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; switch ((cell.Field as PivotGridAggregateField).DataField) { //case "KgLt": // cell.BackColor = Color.Silver; // cell.Font.Bold = true; // cell.HorizontalAlign = HorizontalAlign.Right; // break; //case "KgLtPro": // double quantity = Convert.ToDouble(cell.DataItem); // cell.BackColor = Color.Silver; // cell.Font.Bold = true; // cell.HorizontalAlign = HorizontalAlign.Right; // break; //default: // cell.BackColor = Color.Silver; // cell.Font.Bold = true; // cell.HorizontalAlign = HorizontalAlign.Right; // break; } } //Red - color the totals Column cells if (cell.CellType == PivotGridDataCellType.ColumnTotalDataCell) { cell.BackColor = Color.LightGray; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; } //Orange - color SubTotales column cells if (cell.CellType == PivotGridDataCellType.RowAndColumnTotal) { cell.BackColor = Color.Silver; cell.Font.Bold = true; } // Azul - Color GrandTotal Column if (cell.CellType == PivotGridDataCellType.RowGrandTotalColumnTotal) { cell.BackColor = Color.Orange; cell.Font.Bold = true; } ///////// Sin efecto //color the column/row grand total cells if (cell.CellType == PivotGridDataCellType.ColumnGrandTotalDataCell) { cell.BackColor = Color.Blue; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; switch ((cell.Field as PivotGridAggregateField).DataField) { //case "KgLt": // cell.BackColor = Color.Silver; // cell.Font.Bold = true; // cell.HorizontalAlign = HorizontalAlign.Right; // break; //case "KgLtPro": // double quantity = Convert.ToDouble(cell.DataItem); // cell.BackColor = Color.Silver; // cell.Font.Bold = true; // cell.HorizontalAlign = HorizontalAlign.Right; // break; //default: // cell.BackColor = Color.Silver; // cell.Font.Bold = true; // cell.HorizontalAlign = HorizontalAlign.Right; // break; } } //color the column AND row grand total cell if (cell.CellType == PivotGridDataCellType.ColumnGrandTotalRowTotal) { cell.BackColor = Color.Pink; cell.Font.Bold = true; } if (cell.CellType == PivotGridDataCellType.RowAndColumnGrandTotal) { cell.BackColor = Color.Violet; cell.Font.Bold = true; } } ////style the row headers based on their level else if (e.Cell is PivotGridRowHeaderCell) { PivotGridRowHeaderCell cell = e.Cell as PivotGridRowHeaderCell; if (cell.ParentIndexes != null && cell.ParentIndexes.Length == 1) { cell.Font.Bold = true; } else { //cell.Font.Italic = false; } } ////style the column headers based on their level else if (e.Cell is PivotGridColumnHeaderCell) { PivotGridColumnHeaderCell cell = e.Cell as PivotGridColumnHeaderCell; if (cell.ParentIndexes != null) { cell.Font.Bold = false; //cell.HorizontalAlign = HorizontalAlign.Center; } } } catch (Exception ex) { lblMensaje.Text = ex.Message; lblMensaje.CssClass = "mensajeError"; } //give a color to the various cells cells }
protected void gsReporteVentas_Zonas_CellDataBound(object sender, PivotGridCellDataBoundEventArgs e) { int importe = 0; try { if (e.Cell is PivotGridDataCell) { PivotGridDataCell cell = e.Cell as PivotGridDataCell; //color all data cells if (cell.CellType == PivotGridDataCellType.DataCell) { cell.Font.Bold = false; cell.BackColor = Color.White; cell.HorizontalAlign = HorizontalAlign.Right; if (cell.ParentColumnIndexes[2].ToString() == "MargenGASTOD") { cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe > 10) { cell.BackColor = Color.Pink; cell.ForeColor = Color.Red; } } if (cell.ParentColumnIndexes[2].ToString() == "UtilidadOperativaP") { cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe > 35) { cell.BackColor = Color.Plum; cell.ForeColor = Color.Purple; } } } //Black - color the Sub totals rows cells if (cell.CellType == PivotGridDataCellType.RowTotalDataCell) { cell.BackColor = Color.PaleGreen; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; if (cell.ParentColumnIndexes[2].ToString() == "MargenGASTOD") { cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe > 10) { cell.BackColor = Color.Pink; cell.ForeColor = Color.Red; } } if (cell.ParentColumnIndexes[2].ToString() == "UtilidadOperativaP") { cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe > 35) { cell.BackColor = Color.Plum; cell.ForeColor = Color.Purple; } } } //Yellow - color the column/row / grand total rows if (cell.CellType == PivotGridDataCellType.RowGrandTotalDataCell) { cell.BackColor = Color.Silver; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; if (cell.ParentColumnIndexes[2].ToString() == "MargenGASTOD") { cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe > 10) { cell.BackColor = Color.Pink; cell.ForeColor = Color.Red; } } if (cell.ParentColumnIndexes[2].ToString() == "UtilidadOperativaP") { cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe > 35) { cell.BackColor = Color.Plum; cell.ForeColor = Color.Purple; } } } //Red if (cell.CellType == PivotGridDataCellType.ColumnTotalDataCell) { cell.BackColor = Color.LightGray; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; if (cell.ParentColumnIndexes[1].ToString() == "2017 MargenGASTOD") { cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe > 10) { cell.BackColor = Color.Pink; cell.ForeColor = Color.Red; } } if (cell.ParentColumnIndexes[1].ToString() == "2017 UtilidadOperativaP") { cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe > 35) { cell.BackColor = Color.Plum; cell.ForeColor = Color.Purple; } } } //Orange - color SubTotales column cells if (cell.CellType == PivotGridDataCellType.RowAndColumnTotal) { cell.BackColor = Color.PaleGreen; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; if (cell.ParentColumnIndexes[1].ToString() == "2017 MargenGASTOD") { cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe > 10) { cell.BackColor = Color.Pink; cell.ForeColor = Color.Red; } } if (cell.ParentColumnIndexes[1].ToString() == "2017 UtilidadOperativaP") { cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe > 35) { cell.BackColor = Color.Plum; cell.ForeColor = Color.Purple; } } } // Azul - Color GrandTotal Column if (cell.CellType == PivotGridDataCellType.RowGrandTotalColumnTotal) { cell.BackColor = Color.Silver; cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Right; if (cell.ParentColumnIndexes[1].ToString() == "2017 MargenGASTOD") { cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe > 10) { cell.BackColor = Color.Pink; cell.ForeColor = Color.Red; } } if (cell.ParentColumnIndexes[1].ToString() == "2017 UtilidadOperativaP") { cell.HorizontalAlign = HorizontalAlign.Right; importe = Convert.ToInt32(cell.DataItem); if (importe > 35) { cell.BackColor = Color.Plum; cell.ForeColor = Color.Purple; } } } } ////style the row headers based on their level else if (e.Cell is PivotGridRowHeaderCell) { PivotGridRowHeaderCell cell = e.Cell as PivotGridRowHeaderCell; if (cell.ParentIndexes != null && cell.ParentIndexes.Length == 1) { cell.Font.Bold = true; //cell.HorizontalAlign = HorizontalAlign.Center; } else { //cell.Font.Italic = false; } } ////style the column headers based on their level else if (e.Cell is PivotGridColumnHeaderCell) { PivotGridColumnHeaderCell cell = e.Cell as PivotGridColumnHeaderCell; if (cell.ParentIndexes != null) { cell.Font.Bold = false; cell.BorderColor = Color.Black; //cell.HorizontalAlign = HorizontalAlign.Center; } } } catch (Exception ex) { lblMensaje.Text = ex.Message; lblMensaje.CssClass = "mensajeError"; } //give a color to the various cells cells }
protected void pgridDetalle_CellDataBound(object sender, Telerik.Web.UI.PivotGridCellDataBoundEventArgs e) { if (e.Cell is PivotGridRowHeaderCell) { if (e.Cell.Controls.Count > 1) { (e.Cell.Controls[0] as Button).Visible = false; } PivotGridRowHeaderCell cell = e.Cell as PivotGridRowHeaderCell; if (vslotCompetenciaColor == cell.Slot) { switch (cell.Field.DataField.ToString()) { case "NB_CLASIFICACION_COMPETENCIA": cell.BorderColor = System.Drawing.ColorTranslator.FromHtml(vProgramasCapacitacion.ElementAt(cell.Slot).CL_COLOR.ToString()); cell.BorderWidth = 2; break; case "NB_COMPETENCIA": cell.BorderColor = System.Drawing.ColorTranslator.FromHtml(vProgramasCapacitacion.ElementAt(cell.Slot).CL_COLOR.ToString()); cell.BorderWidth = 2; break; case "CL_TIPO_COMPETENCIA": cell.BorderColor = System.Drawing.ColorTranslator.FromHtml(vProgramasCapacitacion.ElementAt(cell.Slot).CL_COLOR.ToString()); vslotCompetenciaColor++; cell.BorderWidth = 2; break; } } } if (e.Cell is PivotGridColumnHeaderCell) { PivotGridColumnHeaderCell cell = e.Cell as PivotGridColumnHeaderCell; switch (cell.Field.DataField.ToString()) { case "NB_EVALUADO": var objetoNecesidad = vProgramasCapacitacion.Where(x => x.NB_EVALUADO.Equals(cell.DataItem.ToString())).FirstOrDefault(); cell.Text = "<a>" + ((objetoNecesidad != null) ? objetoNecesidad.CL_EVALUADO.ToString() : "") + "</a> <br>" + cell.DataItem.ToString(); break; case "NB_PUESTO": var vobjetoNecesidadPuesto = vProgramasCapacitacion.Where(x => x.NB_PUESTO.Equals(cell.DataItem.ToString())).FirstOrDefault(); cell.Text = "<a>" + ((vobjetoNecesidadPuesto != null) ? vobjetoNecesidadPuesto.CL_PUESTO.ToString() : "") + "</a> <br>" + cell.DataItem.ToString(); break; default: break; } } if (e.Cell is PivotGridDataCell) { PivotGridDataCell cell = e.Cell as PivotGridDataCell; if (cell.Field.DataField.ToString().Equals("PR_RESULTADO")) { string Valor = cell.Text.ToString(); Decimal Devalor = Decimal.Parse(Valor); if (Devalor == 100) { cell.CssClass = "divBlanco"; cell.HorizontalAlign = HorizontalAlign.Right; } else if (Devalor >= 70) { cell.CssClass = "divAmarrillo"; cell.BorderColor = System.Drawing.Color.White; cell.BorderWidth = 1; cell.HorizontalAlign = HorizontalAlign.Right; } else if (Devalor >= 0 & Devalor < 70) { cell.CssClass = "divRojo"; cell.BorderColor = System.Drawing.Color.White; cell.BorderWidth = 1; cell.HorizontalAlign = HorizontalAlign.Right; } else { cell.CssClass = "divGrid"; cell.Text = "N/A"; } } } }