Hi,
I'm testing RadGrid filters and I have problems with template filters.
I want to have a template filter for a column binded to a datetime datafield, for filtering between two dates. The template has these controls:
- a Date picker for start date.
- a Date picker for end date.
- a button to apply/clear the filter.
These are pieces of the code I'm using:
- ASPX:
- CS:
When I click the filter button the command is fired and the code for 'cmdFilterDT' is executed, but no changes are displayed in the grid (I have a rule from myGrid to myGrid in an RadAjaxManager for refreshing the changes).
Anyone can help me? I've been reading the help and the grid forum but I don't find any solution to this method for using template filters.
Thanks in advance,
John.
I'm testing RadGrid filters and I have problems with template filters.
I want to have a template filter for a column binded to a datetime datafield, for filtering between two dates. The template has these controls:
- a Date picker for start date.
- a Date picker for end date.
- a button to apply/clear the filter.
These are pieces of the code I'm using:
- ASPX:
... <telerik:GridBoundColumn DataField="DateTimeFieldDB" DataType="System.DateTime" FilterControlAltText="Filter DateTimeFieldDB column" HeaderText="Date/Time" SortExpression="DateTimeFieldDB" UniqueName="DateTimeCol" HeaderButtonType="LinkButton"> <HeaderStyle Width="150px" /> <FilterTemplate> <telerik:RadDatePicker ID="FromDT" runat="server" Width="70px"/> <telerik:RadDatePicker ID="ToDT" runat="server" Width="70px"/> <telerik:RadButton ID="btnFilterDT" runat="server" Text="Filter" CommandName="cmdFilterDT"> </telerik:RadButton> </FilterTemplate> </telerik:GridBoundColumn>...- CS:
protected void myGrid_ItemCommand(object sender, GridCommandEventArgs e) { switch (e.CommandName) { case "cmdFilterDT": GridColumn column = myGrid.MasterTableView.GetColumnSafe("DateTimeCol"); GridItem[] fItems = myGrid.MasterTableView.GetItems(GridItemType.FilteringItem); RadDatePicker dpFrom = (RadDatePicker)fItems[0].FindControl("FromDT"); RadDatePicker dpTo = (RadDatePicker)fItems[0].FindControl("ToDT"); string sDateFrom = string.Format("{0: dd/MM/yyyy}", dpFrom.SelectedDate); string sDateTo = string.Format("{0: dd/MM/yyyy}", dpTo.SelectedDate); if (dpFrom.SelectedDate.ToString() != string.Empty && dpTo.SelectedDate.ToString() != string.Empty) { column.CurrentFilterFunction = GridKnownFunction.Between; column.CurrentFilterValue = string.Format("{0} {1}", sDateFrom, sDateTo); } else { column.CurrentFilterFunction = GridKnownFunction.NoFilter; column.CurrentFilterValue = ""; } myGrid.MasterTableView.Rebind(); break; } }When I click the filter button the command is fired and the code for 'cmdFilterDT' is executed, but no changes are displayed in the grid (I have a rule from myGrid to myGrid in an RadAjaxManager for refreshing the changes).
Anyone can help me? I've been reading the help and the grid forum but I don't find any solution to this method for using template filters.
Thanks in advance,
John.