# GridView Filtering on GridViewTemplateColumn

**URL:** <https://forum.dotvvm.com/t/gridview-filtering-on-gridviewtemplatecolumn/109>\
**Category:** Discussion in English\
**Tags:** business-pack\
**Created:** [January 10, 2024, 11:29pm UTC](https://forum.dotvvm.com/t/gridview-filtering-on-gridviewtemplatecolumn/109 "2024-01-10T23:29:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thatdbme](https://forum.dotvvm.com/user_avatar/forum.dotvvm.com/thatdbme/32/14_2.png) [@thatdbme](https://forum.dotvvm.com/u/thatdbme)\
**Post date:** [January 10, 2024, 11:29pm UTC](https://forum.dotvvm.com/t/gridview-filtering-on-gridviewtemplatecolumn/109/1 "2024-01-10T23:29:34Z")

</div>

Filtering is not available when using a `GridViewTemplateColumn`.

I was able to get a basic filter working with the method shown below. But it takes a lot of code to accomplish. Also, the output UI is not the same and I don’t know how to provide any of the other filtering operators.

Dothml

```auto
<bp:GridView DataSource="{value: DataSet}"
             ShowTableWhenNoData="true"
             Class-hide-filters={value: !_this.EnableFiltering}
             FilterPlacement="SeparateHeaderRow">
    <Columns>
        <bp:GridViewTextColumn Value="{value: Name}"
                               HeaderText="Name"
                               AllowFiltering />
    <bp:GridViewTemplateColumn HeaderText="Assigned Word" AllowFiltering>
        <FilterTemplate>
            <bp:TextBox Text="{value: _root.AssignedWordFilter}"
                        Changed="{command: _root.OnAssignedWordFilterFilterChanged()}" />
        </FilterTemplate>
        <span class="dotvvm-bp-primitive_text">{{value: AssignedWord}}</span>
    </bp:GridViewTemplateColumn>
    </Columns>
</bp:GridView>

```

Viewmodel

```auto
public void OnAssignedWordFilterFilterChanged()
{
    FilterCondition filterCondition = null;

    // Check for an existing custom filter. if there is one, delete it
    foreach (var filter in EcxGrid.DataSet.FilteringOptions.FilterGroup.Filters.Cast<FilterCondition>())
    {
        if (filter.FieldName.Equals("AssignedWord"))
        {
            filterCondition = filter;
        }
    }
    if(filterCondition != null)
        EcxGrid.DataSet.FilteringOptions.FilterGroup.Filters.Remove(filterCondition);

    // If there is a filter value, create and add the new filter
    if (!string.IsNullOrEmpty(AssignedWordFilter))
    {
        filterCondition = new FilterCondition()
        {
            FieldDisplayName = "",
            FieldName = "AssignedWord", // Must match the name of the field in the GridView
            Operator = FilterOperatorType.Contains,
            Value = AssignedWordFilter
        };

        EcxGrid.DataSet.FilteringOptions.FilterGroup.Filters.Add(filterCondition);
    }

    EcxGrid.DataSet.RequestRefresh();
}

```

The output  
 ![image](https://forum.dotvvm.com/uploads/default/original/1X/5071af8cac5283867c149d14b8c5d7f2d3cfb0a4.png)

**What is the best way to add the same type of filtering, preferably with the same filtering options, as the default filtering?**

The goal is to be able to filter the same as a `GridViewTextColumn` but also have additional formatting (no additional formatting added to the example above).
