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

fill and use custom filter values in GridGroupingControl

Hello!
Help me please how I could fill and use custom filter values in GridGroupingControl?

3 Replies

AD Administrator Syncfusion Team October 6, 2006 07:29 AM UTC

Hi Vitaliy,

Issue 1:

Do you want to use filter record? If so, you can use FilterRecords collection to find the filter records in a grid. Here is a code snippet

GridTable table = this.grid.Table;
foreach( Record frec in table.FilteredRecords)
{
Console.WriteLine("Record Info : " + frec);
}

Issue 2:

Do you want to use filtered string? If so, you can use GetFilterBarText method to get the filterbar text in a column of the grid. Below is a code.

GridTableFilterBarCellRenderer cr = this.grid.TableControl.CellRenderers["FilterBarCell"] as GridTableFilterBarCellRenderer;
if( cr != null)
{
Console.WriteLine( cr.GetFilterBarText(this.grid.TableModel[3,2] ));
}

Best Regards,
Haneef


VI Vitaliy October 6, 2006 09:29 AM UTC

Hi Haneef,
not, I want fill drop-down filter to my custom values. And when user clicked on filter list, I want set custom filter. This code raize error, index list out of bounds :

int RowIndex = -1;
int colIndex = -1;
bool IsDropDown = false;
string ColumnName = string.Empty;

private void clientGridControl_TableControlCurrentCellShowingDropDown(object sender, GridTableControlCurrentCellShowingDropDownEventArgs e)
{
GridTableCellStyleInfo table = e.TableControl.CurrentCell.Renderer.CurrentStyle as GridTableCellStyleInfo;
RowIndex = e.TableControl.CurrentCell.RowIndex;
colIndex = e.TableControl.CurrentCell.ColIndex;
IsDropDown = true;
GridComboBoxCellRenderer cr = e.TableControl.CurrentCell.Renderer as GridComboBoxCellRenderer;
if (table.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.FilterBar)
{
ColumnName = table.TableCellIdentity.Column.MappingName;
if (ColumnName == "StateString" && cr != null)
{
//cr.ListBoxPart.Items.Clear();
foreach (DataRow row in _dataService.MasrerItemsObjects.Tables[DataService.STATE].Rows)
{
cr.ListBoxPart.Items.Add(row[DataService.STATE_NAME]);
}
cr.ListBoxPart.Click += new EventHandler(ListBoxPart_Click);
}
}
}

private void ListBoxPart_Click(object sender, EventArgs e)
{
ListBox list = sender as ListBox;
if (list.SelectedIndex != -1)
{
if (ColumnName == "StateString")
{
if (IsDropDown)
{
IsDropDown = false;
this.clientGridControl.Engine.TableDescriptor.RecordFilters.Remove(ColumnName);
if (list.SelectedIndex > 2)
{
this.clientGridControl.Engine.TableDescriptor.RecordFilters.Add(ColumnName, FilterCompareOperator.Like, "*" + list.SelectedItem + "*");
}
}
list.SelectedIndex = 0;
}
}
}


AD Administrator Syncfusion Team October 6, 2006 10:22 AM UTC

Hi Vitaliy,

Please refer to this KB article for customize the filterbar entry in a grid.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=323

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon