New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Reduce cell width of RadGrid range filtering

DESCRIPTION

The GridDateTimeColumn of RadGrid provides convenient built-in range filtering functionality:

<telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime"
    FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
    SortExpression="OrderDate" UniqueName="OrderDate" EnableRangeFiltering="true"
    EnableTimeIndependentFiltering="true">
</telerik:GridDateTimeColumn>

Since this requires 2 picker controls to be generated, the width of the filtering cell may increase beyond its standard size.

SOLUTION

To reduce this cell width, you can put the pickers in two lines:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridFilteringItem)
    {
        GridFilteringItem filterItem = e.Item as GridFilteringItem;
        (filterItem["OrderDate"].Controls[3] as LiteralControl).Text = "<br />To: ";
    }
}
Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs)
    If TypeOf e.Item Is GridFilteringItem Then
        Dim filterItem As GridFilteringItem = TryCast(e.Item, GridFilteringItem)
        (TryCast(filterItem("OrderDate").Controls(3), LiteralControl)).Text = "<br />To: "
    End If
End Sub
In this article
Not finding the help you need? Improve this article