Hello All,
I have simple radgrid with to/from date filter option. But when I change the dates in the filter, its not updating the grid. Following is my simple code. I have tried everything in the tutorial, but no luck. Any help is appreciated.
<telerik:RadGrid RenderMode="Lightweight" ID="rgScreening" runat="server" Width="100%" Enabled ="true"
FilterItemStyle-BackColor="#e6e6e6" FilterItemStyle-BorderStyle="Solid" OnPreRender="rgScreening_PreRender"
OnItemCommand="rgScreening_ItemCommand">
<HeaderStyle CssClass="gridViewHeader" />
<PagerStyle Mode="NumericPages" CssClass="gridViewPager" />
<ItemStyle CssClass="gridViewRow" />
<AlternatingItemStyle CssClass="gridViewAltRow" />
<SelectedItemStyle CssClass="gridViewSelected" />
<MasterTableView AllowSorting="true" PageSize="10" AllowPaging="True" Width="100%" AutoGenerateColumns="false" CommandItemDisplay="None"
AllowFilteringByColumn="true">
<CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="false" />
<Columns>
<telerik:GridBoundColumn UniqueName="ProviderOrOwner" DataField="ProviderOrOwner" HeaderText="Provider/Owner">
<FilterTemplate>
<telerik:RadComboBox RenderMode="Lightweight" runat="server" ID="rcbProviderOrOwner"
SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("ProviderOrOwner").CurrentFilterValue %>'
OnClientSelectedIndexChanged="ProviderOrOwnerSelectedIndexChanged" Width="80px">
<Items>
<telerik:RadComboBoxItem runat="server" Text="All"/>
<telerik:RadComboBoxItem runat="server" Text="Provider" Value="Provider" />
<telerik:RadComboBoxItem runat="server" Text="Owner" Value="Owner" />
</Items>
</telerik:RadComboBox>
<telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
<script type="text/javascript">
function ProviderOrOwnerSelectedIndexChanged(sender, args) {
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
tableView.filter("ProviderOrOwner", args.get_item().get_value(), "EqualTo");
}
</script>
</telerik:RadScriptBlock>
</FilterTemplate>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="ScreeningDate" DataField="ScreeningDate" HeaderText="Screening Date" DataFormatString="{0:D}" >
<FilterTemplate>
<span style="width:50px; font-weight:bold; text-align:right">From</span>
<telerik:RadDatePicker RenderMode="Lightweight" ID="FromScreeningDatePicker" runat="server" Width="120px" ClientEvents-OnDateSelected="FromDateSelected"
MinDate='<%# Convert.ToDateTime("01/01/1900")%>' MaxDate='<%# Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy"))%>'
DbSelectedDate='<%# startDate %>' FocusedDate="01/01/2016"
DateInput-ForeColor="Black" Calendar-CalendarTableStyle-BackColor="#cccccc" Calendar-BackColor="White" Calendar-HeaderStyle-BackColor="White"
Calendar-TitleStyle-BackColor="White" DateInput-BorderColor="Black"/>
<span style="width:50px; font-weight:bold; text-align:right">To</span>
<telerik:RadDatePicker RenderMode="Lightweight" ID="ToScreeningDatePicker" runat="server" Width="120px" ClientEvents-OnDateSelected="ToDateSelected"
MinDate='<%# Convert.ToDateTime("01/01/1900")%>' MaxDate='<%# Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy"))%>'
DbSelectedDate='<%# endDate %>' FocusedDate='<%# Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy"))%>'
DateInput-ForeColor="Black" Calendar-CalendarTableStyle-BackColor="#cccccc" Calendar-BackColor="White" Calendar-HeaderStyle-BackColor="White"
Calendar-TitleStyle-BackColor="White" DateInput-BorderColor="Black"></telerik:RadDatePicker>
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<script type="text/javascript">
function FromDateSelected(sender, args) {
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
var ToPicker = $find('<%# ((GridItem)Container).FindControl("ToScreeningDatePicker").ClientID %>');
var fromDate = FormatSelectedDate(sender);
var toDate = FormatSelectedDate(ToPicker);
tableView.filter("ScreeningDate", fromDate + " " + toDate, "Between");
}
function ToDateSelected(sender, args) {
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
var FromPicker = $find('<%# ((GridItem)Container).FindControl("FromScreeningDatePicker").ClientID %>');
var fromDate = FormatSelectedDate(FromPicker);
var toDate = FormatSelectedDate(sender);
var dtfilter = fromDate + " " + toDate
tableView.filter("ScreeningDate", tfilter, "Between");
}
function FormatSelectedDate(picker) {
var date = picker.get_selectedDate();
var dateInput = picker.get_dateInput();
var formattedDate = dateInput.get_dateFormatInfo().FormatDate(date, "MM/dd/yyyy hh:mm:ss tt");
return formattedDate;
}
</script>
</telerik:RadScriptBlock>
</FilterTemplate>
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>