Hi all,
Is it possible to make a column invisible in the conditional formatting dialog. We have some primary key fields which are hidden (IsVisible = False + IsVisibleInColumnChooser = False), but still i see the columns in the conditional formatting dialog.
Any ideas?
Maarten
Is it possible to make a column invisible in the conditional formatting dialog. We have some primary key fields which are hidden (IsVisible = False + IsVisibleInColumnChooser = False), but still i see the columns in the conditional formatting dialog.
Any ideas?
Maarten
6 Answers, 1 is accepted
0
Hello Maarten,
Thank you for writing.
Yes, this can be done by using a customized conditional formatting form. In order to customize the form you should replace the default header cell in RadGridView:
And here is the code for the customized conditional formatting form:
I hope this helps.
Kind regards,
Jack
the Telerik team
Thank you for writing.
Yes, this can be done by using a customized conditional formatting form. In order to customize the form you should replace the default header cell in RadGridView:
void
radGridView1_CreateCell(
object
sender, GridViewCreateCellEventArgs e)
{
if
(e.CellType ==
typeof
(GridHeaderCellElement))
{
e.CellType =
typeof
(CustomHeaderCell);
}
}
public
class
CustomHeaderCell : GridHeaderCellElement
{
public
CustomHeaderCell(GridViewColumn column, GridRowElement row)
:
base
(column, row)
{
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(GridHeaderCellElement);
}
}
protected
override
ConditionalFormattingForm CreateConditionalFormattingForm()
{
return
new
CustomConditionalFormattingForm(
this
.GridControl,
this
.ViewTemplate,
this
.ColumnInfo
as
GridViewDataColumn,
this
.ElementTree.ThemeName);
}
}
And here is the code for the customized conditional formatting form:
public
class
CustomConditionalFormattingForm : ConditionalFormattingForm
{
public
CustomConditionalFormattingForm(RadGridView radGridView, GridViewTemplate template, GridViewDataColumn column,
string
themeName)
:
base
(radGridView, template, column, themeName)
{
}
protected
override
void
OnLoad(EventArgs e)
{
base
.OnLoad(e);
RadDropDownList list = (RadDropDownList)
this
.Controls[
"radComboBoxColumns"
];
for
(
int
i = list.Items.Count-1; i>=0; i--)
{
RadListDataItem item = list.Items[i];
GridViewColumn column = (GridViewColumn)item.Value;
if
(column.Name ==
"ID"
)
{
list.Items.RemoveAt(i);
}
}
}
}
I hope this helps.
Kind regards,
Jack
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Maarten
Top achievements
Rank 1
answered on 29 Aug 2012, 01:52 PM
Hi Jack,
Once again thx for the reply!
I just tried to implement your code snippet. But it seems the version I'm using for "Telerik.WinControls.UI, 2012.2.726.40" has no protected method "CreateConditionalFormattingForm"...
Since not all columns which we want to hide are ID columns I also think we are going to use the following:
Once again thx for the reply!
I just tried to implement your code snippet. But it seems the version I'm using for "Telerik.WinControls.UI, 2012.2.726.40" has no protected method "CreateConditionalFormattingForm"...
Since not all columns which we want to hide are ID columns I also think we are going to use the following:
if
(!column.IsVisible && !column.VisibleInColumnChooser)
{
list.Items.RemoveAt(i);
}
0
Hi Maarten,
I apologize. I used the internal development version of RadControls for WinForms to create the sample. This method will be available in our upcoming Q3 release in October. Currently, it is not possible to replace the default conditional formatting form in RadGridView. I hope this time frame is OK for you.
Should you have other questions, do not hesitate to ask.
Kind regards,
Jack
the Telerik team
I apologize. I used the internal development version of RadControls for WinForms to create the sample. This method will be available in our upcoming Q3 release in October. Currently, it is not possible to replace the default conditional formatting form in RadGridView. I hope this time frame is OK for you.
Should you have other questions, do not hesitate to ask.
Kind regards,
Jack
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Maarten
Top achievements
Rank 1
answered on 30 Aug 2012, 12:41 PM
Hi Jack,
No problem. We will wait for the upcoming Q3 release.
Greetings,
Maarten
No problem. We will wait for the upcoming Q3 release.
Greetings,
Maarten
0
Wesley
Top achievements
Rank 1
answered on 08 Nov 2012, 10:38 AM
Hi,
I'm a colleague of Maarten and I tried the solution.
It worked but I wrote a custom formatting form that is a little different:
Problem solved.
Thanks!
I'm a colleague of Maarten and I tried the solution.
It worked but I wrote a custom formatting form that is a little different:
public
class
CustomTelerikConditionalFormattingForm : ConditionalFormattingForm
{
public
CustomTelerikConditionalFormattingForm(RadGridView radGridView, GridViewTemplate template, GridViewDataColumn column,
string
themeName)
:
base
(radGridView, template, column, themeName)
{
}
protected
override
void
OnLoad(EventArgs e)
{
base
.OnLoad(e);
var columnDropDownList = (RadDropDownList)Controls[
"radComboBoxColumns"
];
for
(var i = columnDropDownList.Items.Count-1; i>=0; i--)
{
RadListDataItem item = columnDropDownList.Items[i];
var column = (GridViewColumn)item.Value;
if
(!column.IsVisible || !column.VisibleInColumnChooser)
{
columnDropDownList.Items.RemoveAt(i);
}
}
}
}
Problem solved.
Thanks!
0
Hello Wesley,
I am glad to hear that you have found a solution for this issue. Thank you for sharing it with the community.
If you have further questions, do not hesitate to contact us.
Regards,
Jack
the Telerik team
I am glad to hear that you have found a solution for this issue. Thank you for sharing it with the community.
If you have further questions, do not hesitate to contact us.
Regards,
Jack
the Telerik team