private int GetCountOfFakeRowCells(PivotGridDataCell cell) { int count = 0; //if aggregates are more than one additional cells are rendered, so we need to exclude their values from the query if (aggregateFields.Count > 1) { if (RadPivotGrid1.AggregatesPosition == PivotGridAxis.Rows) { if (cell.CellType != PivotGridDataCellType.RowTotalDataCell && cell.CellType != PivotGridDataCellType.ColumnGrandTotalRowTotal) { count++; } } } // if row total or grand total cell is hit we need to escape its values from query if (cell.CellType == PivotGridDataCellType.RowTotalDataCell || cell.CellType == PivotGridDataCellType.ColumnGrandTotalRowTotal || cell.CellType == PivotGridDataCellType.RowGrandTotalDataCell) { count++; } return(count); }
private int GetCountOfFakeColumnCells(PivotGridDataCell cell) { int count = 0; if (aggregateFields.Count > 1) { if (RadPivotGrid1.AggregatesPosition == PivotGridAxis.Columns) { if (cell.CellType == PivotGridDataCellType.DataCell || cell.CellType == PivotGridDataCellType.RowTotalDataCell || cell.CellType == PivotGridDataCellType.RowAndColumnTotal || cell.CellType == PivotGridDataCellType.RowGrandTotalDataCell || cell.CellType == PivotGridDataCellType.ColumnGrandTotalRowTotal) { count++; } } } // if column total or grand total cell is hit we need to escape its values from query if (cell.CellType == PivotGridDataCellType.ColumnTotalDataCell || cell.CellType == PivotGridDataCellType.RowAndColumnTotal || cell.CellType == PivotGridDataCellType.ColumnGrandTotalRowTotal || cell.CellType == PivotGridDataCellType.ColumnGrandTotalDataCell || cell.CellType == PivotGridDataCellType.RowGrandTotalColumnTotal) { count++; } return(count); }
public string GetCommandArguments(PivotGridDataCell cell) { // True when first cell of each row is hit if (currentRowID != cell.NamingContainer.UniqueID) { index = 0; currentRowID = cell.NamingContainer.UniqueID; countOfFakeRowCells = GetCountOfFakeRowCells(cell); } object[] rowIndexes = cell.ParentRowIndexes; object[] columnIndexes = cell.ParentColumnIndexes; int rowIndexesCount = rowIndexes.Count(); int columnIndexesCount = columnIndexes.Count(); int countOfFakeColumnCells = allFakeColumnCells[index]; rowIndexesCount -= countOfFakeRowCells; columnIndexesCount -= countOfFakeColumnCells; StringBuilder buider = BuildArguments(rowIndexes, columnIndexes, rowIndexesCount, columnIndexesCount); return(buider.ToString()); }
protected void gsContadorAccesos_CellDataBound(object sender, PivotGridCellDataBoundEventArgs e) { try { if (e.Cell is PivotGridDataCell) { PivotGridDataCell cell = e.Cell as PivotGridDataCell; if (cell.CellType == PivotGridDataCellType.DataCell) { cell.BackColor = Color.FromArgb(255, 255, 247); cell.Font.Bold = false; //if (cell.ParentColumnIndexes[2].ToString() == "Sum of TotalPrice") //{ // cell.Font.Italic = true; //} } } } catch (Exception ex) { lblMensaje.Text = ex.Message; lblMensaje.CssClass = "mensajeError"; } //give a color to the various cells cells }
protected void rgEvaluacionesTransversalesporPersonal_CellDataBound(object sender, PivotGridCellDataBoundEventArgs e) { int porcentaje; string valor_desarrolladas = string.Empty; obtenervalor(valor_desarrolladas); int parametroCompetenciasDesarrolladas = BE_EVALUACIONES_COMPETENCIAS_TRANSVERSALES.VALOR; if (e.Cell is PivotGridDataCell) { PivotGridDataCell cell = e.Cell as PivotGridDataCell; if (cell.CellType == PivotGridDataCellType.DataCell) { if (cell != null) { switch ((cell.Field as PivotGridAggregateField).DataField) { //color the cells showing totals for TotalPrice based on their value case "PORCENTAJE": if (cell.DataItem != null && cell.DataItem.ToString().Length > 0) { decimal price = Convert.ToDecimal(cell.DataItem); porcentaje = Convert.ToInt32(price * 100); if (porcentaje >= parametroCompetenciasDesarrolladas) { string valor = string.Empty; obtenerColorVerde(valor); string color = BE_EVALUACIONES_COMPETENCIAS_TRANSVERSALES.VALOR_COLOR; cell.BackColor = ColorTranslator.FromHtml(color); } else if (porcentaje < parametroCompetenciasDesarrolladas) { string valor = string.Empty; obtenerColorAmarillo(valor); string color = BE_EVALUACIONES_COMPETENCIAS_TRANSVERSALES.VALOR_COLOR; cell.BackColor = ColorTranslator.FromHtml(color); } } break; } } } } }
// This methos is executed only for the first cell from the first row private void PopulateFakeColumnsCellCollection(PivotGridDataCell cell) { PivotGridDataItem item = cell.NamingContainer as PivotGridDataItem; cellsCount = item.Cells.Count; allFakeColumnCells = new int[cellsCount]; firstRowID = item.UniqueID; for (int i = 0; i < cellsCount; i++) { int countOfFakeCells = GetCountOfFakeColumnCells(item.Cells[i] as PivotGridDataCell); allFakeColumnCells[i] = countOfFakeCells; } }
void RadPivotGrid1_CellDataBound(object sender, PivotGridCellDataBoundEventArgs e) { PivotGridDataCell cell = e.Cell as PivotGridDataCell; if (cell != null) { // If this is the first data cell we need to populate the collecion which fake columns cells count if (isFirstDataCell) { PopulateFakeColumnsCellCollection(cell); isFirstDataCell = false; } // We do not need to attach onclick event on cell which does not have values if (cell.DataItem != null) { string argument = GetCommandArguments(cell); string script = string.Format("OpenDetailsWindow('{0}')", argument); cell.Attributes.Add("onclick", script); } index++; } }
protected void rpgReporte_CellDataBound(object sender, Telerik.Web.UI.PivotGridCellDataBoundEventArgs e) { int vNoValorCompetencia; if (e.Cell is PivotGridRowHeaderCell) { if (e.Cell.Controls.Count > 1) { (e.Cell.Controls[0] as Button).Visible = false; } } if (e.Cell is PivotGridDataCell) { PivotGridDataCell celda = (PivotGridDataCell)e.Cell; e.Cell.HorizontalAlign = HorizontalAlign.Center; if (celda.IsGrandTotalCell) { vNoValorCompetencia = Convert.ToInt32((decimal)e.Cell.DataItem); if (vNoValorCompetencia < 70) { e.Cell.ForeColor = System.Drawing.Color.Red; } else if (vNoValorCompetencia >= 70 & vNoValorCompetencia < 85) { e.Cell.ForeColor = System.Drawing.Color.Gold; } else if (vNoValorCompetencia >= 85) { e.Cell.ForeColor = System.Drawing.Color.Green; } } } }
private int GetCountOfFakeColumnCells(PivotGridDataCell cell) { int count = 0; if (aggregateFields.Count > 1) { if (RadPivotGrid1.AggregatesPosition == PivotGridAxis.Columns) { if (cell.CellType == PivotGridDataCellType.DataCell || cell.CellType == PivotGridDataCellType.RowTotalDataCell || cell.CellType == PivotGridDataCellType.RowAndColumnTotal || cell.CellType == PivotGridDataCellType.RowGrandTotalDataCell || cell.CellType == PivotGridDataCellType.ColumnGrandTotalRowTotal) { count++; } } } // if column total or grand total cell is hit we need to escape its values from query if (cell.CellType == PivotGridDataCellType.ColumnTotalDataCell || cell.CellType == PivotGridDataCellType.RowAndColumnTotal || cell.CellType == PivotGridDataCellType.ColumnGrandTotalRowTotal || cell.CellType == PivotGridDataCellType.ColumnGrandTotalDataCell || cell.CellType == PivotGridDataCellType.RowGrandTotalColumnTotal) { count++; } return count; }
public string GetCommandArguments(PivotGridDataCell cell) { // True when first cell of each row is hit if (currentRowID != cell.NamingContainer.UniqueID) { index = 0; currentRowID = cell.NamingContainer.UniqueID; countOfFakeRowCells = GetCountOfFakeRowCells(cell); } object[] rowIndexes = cell.ParentRowIndexes; object[] columnIndexes = cell.ParentColumnIndexes; int rowIndexesCount = rowIndexes.Count(); int columnIndexesCount = columnIndexes.Count(); int countOfFakeColumnCells = allFakeColumnCells[index]; rowIndexesCount -= countOfFakeRowCells; columnIndexesCount -= countOfFakeColumnCells; StringBuilder buider = BuildArguments(rowIndexes, columnIndexes, rowIndexesCount, columnIndexesCount); return buider.ToString(); }
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 pgCompetencias_CellDataBound(object sender, Telerik.Web.UI.PivotGridCellDataBoundEventArgs e) { int vNoValorCompetencia; if (e.Cell is PivotGridColumnHeaderCell) { E_COMPARACION_COMPETENCIA vEmpleado = ComparacionCompetencias.Where(t => t.CL_EMPLEADO.Equals(e.Cell.DataItem.ToString())).FirstOrDefault(); if (vEmpleado != null) { e.Cell.ToolTip = vEmpleado.NB_EMPLEADO; e.Cell.Text = String.Format("<a href='#' onclick='OpenInventario({1})'>{0}</a>", vEmpleado.CL_EMPLEADO, vEmpleado.ID_EMPLEADO); oListaEmpleados.Add(e.Cell.DataItem.ToString()); } } if (e.Cell is PivotGridRowHeaderCell) { if (e.Cell.Controls.Count > 1) { (e.Cell.Controls[0] as Button).Visible = false; } } else if (e.Cell is PivotGridDataCell) { PivotGridDataCell celda = (PivotGridDataCell)e.Cell; if (celda.IsGrandTotalCell) { celda.Text = "<div style=\"text-align: center;\">" + obtenerPromedio(oListaEmpleados[celda.ColumnIndex]).ToString() + "</div>"; } else { System.Web.UI.HtmlControls.HtmlGenericControl divColor = celda.FindControl("divColorComparacion") as System.Web.UI.HtmlControls.HtmlGenericControl; System.Web.UI.HtmlControls.HtmlGenericControl divPromedio = celda.FindControl("divPromedio") as System.Web.UI.HtmlControls.HtmlGenericControl; System.Web.UI.HtmlControls.HtmlGenericControl divNa = celda.FindControl("divNa") as System.Web.UI.HtmlControls.HtmlGenericControl; System.Web.UI.HtmlControls.HtmlGenericControl divNc = celda.FindControl("divNc") as System.Web.UI.HtmlControls.HtmlGenericControl; if (e.Cell.DataItem != null) { if ((decimal)e.Cell.DataItem == Convert.ToDecimal(-1)) { //e.Cell.Text = "<div style=\"text-align: center;\">N/C</div>"; //e.Cell.CssClass = "PotencialNC"; divNa.Style.Add("display", "none"); divNc.Style.Add("display", "block"); divPromedio.Style.Add("display", "none"); divColor.Style.Add("background-color", "gray"); } else if (celda.ParentRowIndexes[2].ToString() == "Total de elementos en común:") { divNa.Style.Add("display", "none"); divNc.Style.Add("display", "none"); divPromedio.Style.Add("display", "block"); divPromedio.Style.Add(" font-weight", "bold"); divColor.Style.Add("background-color", "white"); } else { vNoValorCompetencia = Convert.ToInt32((decimal)e.Cell.DataItem); if (vNoValorCompetencia == 0) { //e.Cell.CssClass = "PotencialPuestoBajo"; this.rtmInfoEmpleados.TargetControls.Add(celda.ClientID, oListaEmpleados[celda.ColumnIndex], true); divNa.Style.Add("display", "none"); divNc.Style.Add("display", "none"); divPromedio.Style.Add("display", "none"); divColor.Style.Add("background-color", "red"); } else if (vNoValorCompetencia == 1) { //e.Cell.CssClass = "PotencialPuestoAlto"; divNa.Style.Add("display", "none"); divNc.Style.Add("display", "none"); divPromedio.Style.Add("display", "none"); divColor.Style.Add("background-color", "green"); this.rtmInfoEmpleados.TargetControls.Add(celda.ClientID, oListaEmpleados[celda.ColumnIndex], true); } else if (vNoValorCompetencia < 70) { //e.Cell.CssClass = "PotencialBajo"; divNa.Style.Add("display", "none"); divNc.Style.Add("display", "none"); divPromedio.Style.Add("display", "block"); divColor.Style.Add("background-color", "red"); } else if (vNoValorCompetencia >= 70 & vNoValorCompetencia <= 90) { //e.Cell.CssClass = "PotencialIntermedio"; divNa.Style.Add("display", "none"); divNc.Style.Add("display", "none"); divPromedio.Style.Add("display", "block"); divColor.Style.Add("background-color", "gold"); } else if (vNoValorCompetencia > 90) { //e.Cell.CssClass = "PotencialAlto"; divNa.Style.Add("display", "none"); divNc.Style.Add("display", "none"); divPromedio.Style.Add("display", "block"); divColor.Style.Add("background-color", "green"); } } } else { divNa.Style.Add("display", "none"); divNc.Style.Add("display", "block"); divPromedio.Style.Add("display", "none"); divColor.Style.Add("background-color", "gray"); } } } }
private int GetCountOfFakeRowCells(PivotGridDataCell cell) { int count = 0; //if aggregates are more than one additional cells are rendered, so we need to exclude their values from the query if (aggregateFields.Count > 1) { if (RadPivotGrid1.AggregatesPosition == PivotGridAxis.Rows) { if (cell.CellType != PivotGridDataCellType.RowTotalDataCell && cell.CellType != PivotGridDataCellType.ColumnGrandTotalRowTotal) { count++; } } } // if row total or grand total cell is hit we need to escape its values from query if (cell.CellType == PivotGridDataCellType.RowTotalDataCell || cell.CellType == PivotGridDataCellType.ColumnGrandTotalRowTotal || cell.CellType == PivotGridDataCellType.RowGrandTotalDataCell) { count++; } return count; }
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 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"; } } } }