We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

custom cell appearance and Sorting

Hi,

I am using GridGroupingControl and have applied cell back color on some condition(for example if in column1 the value of any cell is 4 set back color for that cell Red).

The problem is if i click on column header in a Grid to sort data, this custom color settings does not move with the cell vlaue in sorted Grid data.

How i Can do this?

Regards
Naveed Afzaal

6 Replies

VA Valli Syncfusion Team June 9, 2007 06:41 AM UTC

Hi Naveed,

Below is a attached sample link which helps you to change the color of the cell based on some condition.

http://websamples.syncfusion.com/samples/Grid.Web/5.1.0.51/Incident-34692/main.htm

When you sort the column or move the column you will get the custom color settings along with the cell value.

The condition I have checked is 'Column Name' and the 'Cell Value' in the OnQueryCellStyleInfo event. When you check the condition based on the column position, on sorting or moving the column its position gets changed and you will not get the custom color settings applied to the cell.

Please let us know if this helps you.

Regards,
Valli


RM Rekha Mallavarapu November 8, 2007 09:07 PM UTC

Hi Valli,

For a given row in the Grid,
- how do I compare the value of a cell_1 with another cell_2 in the SAME ROW and then color code Cell_2.
- Cell_2 will be orange if the value of Cell_2 is less than the Cell_1
- and red if the value of the Cell_2 is greater than Cell_1.

Can I use QueryCellStyleInfo? Since it goes Cell by Cell, how do I get to the prvious Cell/Cells in the same row?

Any Help would be great!

Thanks,

Rekha


RS Rajarajeswari S Syncfusion Team November 9, 2007 01:44 PM UTC


Hi Rekha,

Thanks for using Syncfusion products.

To apply styles to the Grid cells we have to use QueryCellStyleInfo event. Please refer the
below code snippet which illustrates how to compare two cell values of the same row and
apply styles to the cells depending on the comparision:

protected void GridGroupingControl1_QueryCellStyleInfo(object sender,
Syncfusion.Web.UI.WebControls.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if ((e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell ||
e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell))
{
if (e.Style.TableCellIdentity.RowIndex ==5)
{
if (e.TableCellIdentity.Column.Name == "Numbers1")
{
val1 = (System.Int32)e.Style.CellValue;
}
if (e.TableCellIdentity.Column.Name == "Numbers2")
{
val2 = (System.Int32)e.Style.CellValue;
}
if ((val2 < val1) && (e.TableCellIdentity.Column.Name == "Numbers2") &&
(e.Style.CellValue.ToString() == val2.ToString()))
e.Style.BackColor = System.Drawing.Color.Blue;
else if ((e.TableCellIdentity.Column.Name == "Numbers1") &&
(e.Style.CellValue.ToString() == val1.ToString()))
e.Style.BackColor = System.Drawing.Color.Orange;
}
}

}
Please have a look at the sample from the below link which illustrates the above:

http://websamples.syncfusion.com/samples/Grid.Web/5.1.0.51/I38963/main.htm

Please let me know if you have any other queries.

Regards,
Raji





RM Rekha Mallavarapu November 12, 2007 05:15 PM UTC

Hi,

Is it possible to export the colors of the Grid Cells with any quick function/method to Excel?

Thanks,

Rekha



RS Rajarajeswari S Syncfusion Team December 26, 2007 04:13 AM UTC



Hi Rekha,

Thanks for using Syncfusion products.

You direct trac incident ID 39034 has been updated. Please follow up with that incident.

Regards,
Raji



RS Rajarajeswari S Syncfusion Team December 26, 2007 09:12 AM UTC


Hi Rekha,

Thanks for using Syncfusion products.

Grid control stroes cell values and cell format styles separately. Cell format style information applies while drawing the cell. It is internal behaviour of the Grid. With the current architecture implementation grid only export the cell value while exporting the Grid not the cell format. We have to change the GroupingGridExcelConverterControlExt according to this. So we have consider this as a feature request, we have notified our development team on this regard and will get back to you once we hear back from them.

Regards,
Raji



Loader.
Live Chat Icon For mobile
Up arrow icon