Tuesday, May 13, 2014

At a DevExpress ASPxGridView, left align copy in numeric column types and get rid of those goofy checkboxes in boolean column types.

Let's mess with a DateTime too while we are at this...

private void Foo_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e)
{
   if (e.DataColumn.FieldName == "PaymentConfigurationId")
   {
      e.Cell.HorizontalAlign = HorizontalAlign.Left;
   }
   if (e.DataColumn.FieldName == "ModifiedDate")
   {
      DateTime dateTime = (DateTime) e.CellValue;
      e.Cell.Text = dateTime.Year.ToString();
   }
   if (e.DataColumn.FieldName == "HasError")
   {
      if ((bool) e.CellValue)
      {
         e.Cell.HorizontalAlign = HorizontalAlign.Left;
         e.Cell.Text = "Error";
      } else {
         e.Cell.Text = "";
      }
   }
}

 
 

Um, wait... the goofy checkboxes will only appear if you are using a dx:GridViewDataColumn instead of a dx:GridViewDataTextColumn in which case they are intentional and not "goofy."

No comments:

Post a Comment