Hi there,
I was wondering (after searching for quiet some time) if it's possible to access directly to the filtering controls.
This in the purpose to add some AutoCompleteCustomSource (nicer than changing all the column type and everything ...)
Thx in advance
I was wondering (after searching for quiet some time) if it's possible to access directly to the filtering controls.
This in the purpose to add some AutoCompleteCustomSource (nicer than changing all the column type and everything ...)
Thx in advance
2 Answers, 1 is accepted
0
Richard Slade
Top achievements
Rank 2
answered on 06 Jan 2011, 05:04 PM
Hi Daniel,
As far as I'm aware, you can't add AutoComplete to a filter. However, there are a number of really good options.
If you change your column to a GridViewComboColumn then the filter will behave as a DropDown too.
All-in-all, there are 3 types of filtering that the RadGridView support.
1: Basic filtering
2: Excel Like Filtering (which may also be excellent for your situation)
3: Custom Filtering
have a look at the presentation onTelerik TV here which explains the three in detail.
If you would like to know more about changing one of your columns to a DropDown column, then let me know and i'll provide you with a sample.
Thanks
Richard
As far as I'm aware, you can't add AutoComplete to a filter. However, there are a number of really good options.
If you change your column to a GridViewComboColumn then the filter will behave as a DropDown too.
All-in-all, there are 3 types of filtering that the RadGridView support.
1: Basic filtering
2: Excel Like Filtering (which may also be excellent for your situation)
3: Custom Filtering
have a look at the presentation onTelerik TV here which explains the three in detail.
If you would like to know more about changing one of your columns to a DropDown column, then let me know and i'll provide you with a sample.
Thanks
Richard
0
Emanuel Varga
Top achievements
Rank 1
answered on 07 Jan 2011, 09:33 AM
Hello Daniel,
You could always create a custom cell editor. Please take a look at the following example:
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
You could always create a custom cell editor. Please take a look at the following example:
using
System;
using
System.Data;
using
System.Windows.Forms;
using
Telerik.WinControls;
using
Telerik.WinControls.UI;
public
partial
class
Form1 : Form
{
private
RadGridView radGridView1;
public
Form1()
{
InitializeComponent();
this
.Controls.Add(radGridView1 =
new
RadGridView());
radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
radGridView1.EnableFiltering =
true
;
radGridView1.CellEditorInitialized +=
new
GridViewCellEventHandler(radGridView1_CellEditorInitialized);
radGridView1.EditorRequired +=
new
EditorRequiredEventHandler(radGridView1_EditorRequired);
radGridView1.Dock = DockStyle.Fill;
}
void
radGridView1_EditorRequired(
object
sender, EditorRequiredEventArgs e)
{
if
(radGridView1.CurrentRow
is
GridViewFilteringRowInfo)
{
if
(e.EditorType ==
typeof
(RadTextBoxEditor))
{
e.EditorType =
typeof
(CustomEditor);
var editor =
new
CustomEditor();
}
}
}
void
radGridView1_CellEditorInitialized(
object
sender, GridViewCellEventArgs e)
{
if
(radGridView1.CurrentRow
is
GridViewFilteringRowInfo)
{
var textBoxEditor = e.ActiveEditor
as
CustomEditor;
if
(textBoxEditor ==
null
)
{
return
;
}
var hostItem = textBoxEditor.EditorElement
as
RadHostItem;
var textBox = hostItem.HostedControl
as
RadTextBox;
var autocompleteStringCollection =
new
AutoCompleteStringCollection();
foreach
(var row
in
radGridView1.Rows)
{
var value = row.Cells[1].Value;
if
(value !=
null
)
{
var valueString = value.ToString();
if
(!autocompleteStringCollection.Contains(valueString))
{
autocompleteStringCollection.Add(valueString);
}
}
}
textBox.AutoCompleteCustomSource = autocompleteStringCollection;
textBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
textBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
textBox.Focus();
}
}
protected
override
void
OnLoad(EventArgs e)
{
base
.OnLoad(e);
radGridView1.DataSource = CreateAndPopulateDataSet();
radGridView1.DataMember =
"Table1"
;
}
public
DataSet CreateAndPopulateDataSet()
{
var songDS =
new
DataSet();
var songTable = songDS.Tables.Add();
//-- Add columns to the data table
songTable.Columns.Add(
"ID"
,
typeof
(
int
));
songTable.Columns.Add(
"Song"
,
typeof
(
string
));
for
(
int
i = 1; i < 10; i++)
{
songTable.Rows.Add(i,
"Song "
+ i);
}
return
songDS;
}
}
public
class
CustomEditor : BaseGridEditor
{
private
RadTextBox radTextBox;
public
CustomEditor()
{
radTextBox =
new
RadTextBox();
radTextBox.TextChanged +=
new
EventHandler(radTextBox_TextChanged);
}
void
radTextBox_TextChanged(
object
sender, EventArgs e)
{
OnValueChanged();
}
protected
override
RadElement CreateEditorElement()
{
return
new
RadHostItem(radTextBox);
}
public
override
object
Value
{
get
{
return
radTextBox.Text;
}
set
{
radTextBox.Text = value.ToString();
}
}
}
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP