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

GGC filter bar row

Hi, Is there a way to programmatically find the row index of the filter bar row in GGC? Ultimately I want to be able to set value of the Filter Bar cell for a given column index and a given value. Thank you

5 Replies

AD Administrator Syncfusion Team July 16, 2005 12:40 AM UTC

If your goal is to set a specific filter value, then you can just set the record filter directly without trying to find a specific row/col.
private void button1_Click(object sender, System.EventArgs e)
{
		RecordFilterDescriptor rf = new RecordFilterDescriptor("ParentDec", new FilterCondition(FilterCompareOperator.Equals,"desc2"));
		this.gridGroupingControl1.TableDescriptor.RecordFilters.Add(rf);
}
Here is a sample. http://www.syncfusion.com/Support/user/uploads/GGC_CM_8bb56774.zip


IV Ivan July 18, 2005 02:17 PM UTC

Thank you. Besides setting RecordFilters, I also would like the filter bar to display the filter criteria: GridTableCellStyleInfo style=null; for(int i=0;i<100;i++) { style = this.mainGrid.TableControl.Model[i, colIdx] as GridTableCellStyleInfo; if (style.TableCellIdentity.TableCellType == GridTableCellType.FilterBarCell) { this.mainGrid.TableControl.CurrentCell.MoveTo(i, colIdx +1); this.mainGrid.TableControl.CurrentCell.BeginEdit(); this.mainGrid.TableControl.CurrentCell.Renderer.ControlText=”Criteria”; this.mainGrid.TableControl.CurrentCell.EndEdit(); break; } } Is there more efficient way of finding a cell on the filterbar? Thank you


AD Administrator Syncfusion Team July 18, 2005 04:35 PM UTC

Another way to do this is to handle the TableControlDrawCellDisplayText and set the Text at that point.
private void groupingGrid1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
{
	GridTableCellStyleInfo style = (GridTableCellStyleInfo) e.Inner.Style;
	if (style.TableCellIdentity.TableCellType == GridTableCellType.FilterBarCell
		&& style.TableCellIdentity.Column.MappingName == "ContactTitle")
	{
		e.Inner.DisplayText = "Criteria";
	}
}


IV Ivan July 18, 2005 07:55 PM UTC

Thank you. This works great. But my goal is to set the filterbar cell value from an external event handler, button_click for instance. How would I do it in this case? Thank you.


AD Administrator Syncfusion Team July 18, 2005 10:44 PM UTC

The default behavior of the filterbar cell is not to accept the setting of its text. But using an event like DrawcellDiplsyText gets around this limitation. If you want to ''set'' a value in a button handler, then you could set these values in some variable (or arraylist or hashtable if you need to hold several), and then use these cached values in DrawCellDisplaytext to provide the value you want to see. To find th efilterbar row, you can look for something like the AddNewRow and then use that location to get at the filter bar row. (or, you could look for grid.Table.FilteredRecords[0] if you are not using the AddnewRow at the top.)
public string criteria = "";
private void groupingGrid1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
{
	GridTableCellStyleInfo style = (GridTableCellStyleInfo) e.Inner.Style;
	if (style.TableCellIdentity.TableCellType == GridTableCellType.FilterBarCell
		&& style.TableCellIdentity.Column.MappingName == "ContactTitle"
		&& criteria.Length > 0)
	{
		e.Inner.DisplayText = criteria;
	}
}
private void button1_Click(object sender, System.EventArgs e)
{
	
	Record rec = this.groupingGrid1.Table.AddNewRecord;
	int row = this.groupingGrid1.Table.DisplayElements.IndexOf(rec);
	int field = this.groupingGrid1.TableDescriptor.NameToField("ContactName");
	int col = this.groupingGrid1.TableDescriptor.FieldToColIndex(field);
	criteria = "CriteriaText";
	this.groupingGrid1.TableControl.RefreshRange(GridRangeInfo.Row(row-1));
}

Loader.
Up arrow icon