Hello,
I want to display "N/A" in the pivot grid when the values are -1
my datasource is flatdatasource
is is possible?
Thanks,
Hi
You can this by using CellControlAttached event of pivot grid. Below is a snippet:
pivotGrid.CellControlAttached += new EventHandler<Infragistics.Controls.Grids.PivotCellControlAttachedEventArgs>(pivotGrid_CellControlAttached);
void pivotGrid_CellControlAttached(object sender, Infragistics.Controls.Grids.PivotCellControlAttachedEventArgs e){ if (e.Cell.Data is ICell) { ICell cell = e.Cell.Data as ICell; if(cell.Value !=null) { int val; if (int.TryParse(cell.Value.ToString(), out val) && val == -1) { cell.SetValue("NA", null, null); } } }}
Thanks alot
but there is something very weird going on,
when i load the page, it gives me the -1 values not the NA
but when i scroll down the grid, then i scroll up, i found the -1 turned to be NA
and the down half values are still -1,
means the hidden part is NA
why is that?
You are right. the content shoud be updated too. so change the code to be like this:
void pivotGrid_CellControlAttached(object sender, Infragistics.Controls.Grids.PivotCellControlAttachedEventArgs e) { if (e.Cell.Data is ICell) { ICell cell = e.Cell.Data as ICell; if (cell.Value != null) { int val; if (int.TryParse(cell.Value.ToString(), out val) && val == 30) { cell.SetValue("NA", null, null); e.Cell.Control.Content = "NA"; } } } pivotGrid.DataColumns[0].ColumnWidth = 200; }
Hi,
When try to sort a column that has NA value in it,
it fires an exception that cannot compare it to double, so how can i resolve it? or at least to capture the sorting event of the column header.
nharake
If yuo want NA to participate in sorting you should give them a double value. So change the follow line of code
cell.SetValue(-1.0, "NA", "NA");
put what value you need instead -1.0. Keep in mind that the value should be double
RegardsTodor
ok thanks it worked,
but in this case when i click to edit the cell having the value NA , i get -1 instead of NA and this is not what i want :S
Is there an alternative solution for displaying NA instead of cellcontrolattached?
because it is making the grid slower, and especially when scrolling
can i put it for loaded, or anything else?
Sorry for delay. There is a property which do this
pivotGrid.EditSettings.EditFormattedValue = true;
Setting it to true will solve the problem
Todor
?