Hello,
I Use winform Q3 2007.
I want to disable filtering feature of an ImageColumns. So i set ;
gridViewImageColumn1.Filter.Function = GridKnownFunction.NoFilter;
But, firstly it doesnt prevent user inputing filter text box of the column,
secondly and most important one, when you input something in the filter textbox of the image coloumn and select some menu item in the filtering context menu ( i mean "equal", "greater", ...menu ) it still wants to filter the expression and so program fails with
System.Data.SyntaxErrorException: The expression contains invalid name
message.
for now, I overcome this case by coding this,
private
void BLSecimDataGrid_MasterGridViewTemplate_FilterChanging(object sender, FilterChangingEventArgs e)
{
if (sender is Telerik.WinControls.UI.GridViewImageColumn)
{
GridViewImageColumn gridViewImageColumn = ((Telerik.WinControls.UI.GridViewImageColumn)sender;
if (!string.IsNullOrEmpty(e.NewStringValue)) e.Cancel = true;
}
}
i think it's a bug and i want to know, if there is another solution without coding and just setting some property :)
Thank you
Serkan APUL.
Question regarding CellFormatting
I have just bought a couple of licenses of radcontrols. And I must say; I am very impressed! It helps me save loads of time.
I have a radgrid filled with data (like this):
Name Bit (should be hidden) Phone
John 1 22445566
Mike 0 44556677
Joan 1 44556677
And I want to change the background-color on Name-cell if Bit is set to 1. The background color for the cell with John and Joan should be yellow. And Mike should stay as it is.
This is normally functionality that I would solve using the OnItemDataBound-event. But now I guess I have to use the CellFormatting-event instead.
I figured out that I could not grab the value of Bit, because the column is hidden (radgridDialog.Columns["myBitField"].IsVisible = false;)
So then I tried to prefix my name-column from my stored procedure. So John and Joan became <pre>John and <pre>Joan. Not the nicest solution I have seen. But I was starting to get desperate. Do anyone have an better idea?
The logic almost work. The only thing I'm having problems with now is to change the value of the cell. My function looks like this:
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) |
{ |
// exclude header element in the data column |
if (e.CellElement.ColumnInfo is GridViewDataColumn && !(e.CellElement.RowElement is GridHeaderRowElement)) |
{ |
GridViewDataColumn column = (GridViewDataColumn)e.CellElement.ColumnInfo; |
if (column.DataField == "Name") |
{ |
if (e.CellElement.Value.ToString().StartsWith("<pre>")) |
{ |
Font font = e.CellElement.Font; |
//What should the line below be? I see that e.CellElement.Value is readonly |
//e.CellElement.SetValue(Telerik.WinControls.RadProperty rd, (object)e.CellElement.Value.ToString().Replace("<pre>", "")); |
e.CellElement.Font = font; |
e.CellElement.BackColor = Color.Yellow; |
e.CellElement.ForeColor = Color.Tomato; |
} |
} |
} |
} |