Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
146 views
So using the RadControl, I think I managed to get it to filter the datetime correctly so it can only do Dates even when times are included in the data source.This is calling the OnItemCommand event for the control.
But, when I do a datasource and a bind(), no results are shown even though the data does exist in the datasource

The control does filtering based on AJAX Requests I believe so how can I follow this convention?
At the end of the day, The data in this scenario is being filtered on the server end and wish to rebind this.

or alternatively, can someone tell me how I can do the date filtering on clientside using the GridDateTimeColumn, so I can obtain the FilterType and the current selected date then finally do a filter?

Thanks
Pavlina
Telerik team
 answered on 05 Apr 2012
6 answers
156 views
I am attempting to apply a date range filter to a GridBoundColumn bound to a DateTime.

<telerik:GridBoundColumn DataField="Created"  FilterControlAltText="Filter Created column"
                    HeaderText="Created" SortExpression="Created" UniqueName="Created">
                     <FilterTemplate>
                     <telerik:RadDatePicker ID="ToCreatedDatePicker" runat="server" Width="85px"
                            MinDate="01-01-2012" DbSelectedDate='<%# EndCreatedDate %>'  ClientEvents-OnDateSelected="ToDateSelected"/>
                        to
                     <telerik:RadDatePicker ID="FromCreatedDatePicker" runat="server" Width="85px" 
                            MinDate="01-01-2000" DbSelectedDate='<%# StartCreatedDate %>' ClientEvents-OnDateSelected="FromDateSelected"/>
<telerik:RadScriptBlock ID="scriptFilterEventDate" runat="server">
                                    <script type="text/javascript">
                                        function FromDateSelected(sender, args) {
                                            var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                            var ToPicker = $find('<%# ((GridItem)Container).FindControl("ToCreatedDatePicker").ClientID %>');
 
                                            var fromDate = FormatSelectedDate(sender);
                                            var toDate = FormatSelectedDate(ToPicker);
 
                                            if (toDate != '') {
                                                tableView.filter("Created", fromDate + " " + toDate, "Between");
                                            }
                                        }
 
                                        function ToDateSelected(sender, args) {
                                            var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                            var FromPicker = $find('<%# ((GridItem)Container).FindControl("FromCreatedDatePicker").ClientID %>');
 
                                            var fromDate = FormatSelectedDate(FromPicker);
                                            var toDate = FormatSelectedDate(sender);
 
                                            if (fromDate != '') {
                                                tableView.filter("Created", fromDate + " " + toDate, "Between");
                                            }
                                        }
 
                                        function FormatSelectedDate(picker) {
                                            var date = picker.get_selectedDate();
                                            var dateInput = picker.get_dateInput();
                                            var formattedDate = dateInput.get_dateFormatInfo().FormatDate(date, dateInput.get_displayDateFormat());
 
                                            return formattedDate;
                                        }
                                    </script>
                                </telerik:RadScriptBlock>
                            </FilterTemplate>
                </telerik:GridBoundColumn>

When the filter is applied I receive the following error message from javascript console.

Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: String was not recognized as a valid DateTime.
Sys.WebForms.PageRequestManager._endPostBackTelerik.Web.UI.WebResource.axd:15
Sys.WebForms.PageRequestManager._parseDeltaTelerik.Web.UI.WebResource.axd:15
Sys.WebForms.PageRequestManager._onFormSubmitCompletedTelerik.Web.UI.WebResource.axd:15
(anonymous function)Telerik.Web.UI.WebResource.axd:6
(anonymous function)Telerik.Web.UI.WebResource.axd:6
Sys.Net.WebRequest.completedTelerik.Web.UI.WebResource.axd:6
_onReadyStateChange

The filter is not applied when this error is received

Any idea what I'm doing wrong here..

Ahmed Ilyas
Top achievements
Rank 1
 answered on 05 Apr 2012
4 answers
138 views
Hi.
Following some examples, I found this:

http://www.telerik.com/community/code-library/aspnet-ajax/general/filtering-range-with-raddatepicker-instances-in-a-custom-filtering-column.aspx

I am trying to filter a data source between 2 selected dates.

I am almost there with the implementation of the solution however the problem is, even when the dates are selected, the SelectedDate on the ItemCommand event is null (Nothing in VB.NET)

any ideas where I have gone wrong?

<telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Center" 
                        HeaderText="DateFilter" SortExpression="DateTime" UniqueName="DateFilter" 
                        AllowFiltering="true" ShowFilterIcon="true" AutoPostBackOnFilter="false" DataType="System.DateTime" 
                        DataField="DateTime" ItemStyle-HorizontalAlign="Left">
  
                        <HeaderStyle Width="90px"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Left" Width="90px"></ItemStyle>
                          
                        <FilterTemplate>
                            <telerik:RadComboBox ID="ddlDateFilter" runat="server" DropDownWidth="200px">   
                                <Items>
                                    <telerik:RadComboBoxItem Text="" Selected="true" />
                                </Items>
                                <ItemTemplate>
                                  
                                    From <telerik:RadDatePicker ID="RadDatePickerFrom" runat="server" onclick="PreventDropDownClose(event);">
                                    </telerik:RadDatePicker>
                                    To <telerik:RadDatePicker ID="RadDatePickerTo" runat="server" onclick="PreventDropDownClose(event);">
                                    </telerik:RadDatePicker>                                    
                                    <asp:Button ID="cmdFilterDates" runat="server" Text="Filter" CommandName="FilterDates" />
                                </ItemTemplate>
                            </telerik:RadComboBox>
                        </FilterTemplate>
                          
                    </telerik:GridTemplateColumn>


Code:

Protected Sub grdShiftObservation_OnItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles grdShiftObservation.ItemCommand
  
        If String.Equals(e.CommandName, "filterdates", StringComparison.OrdinalIgnoreCase) Then
  
            Dim cell As TableCell = CType(e.Item, Telerik.Web.UI.GridFilteringItem)("DateFilter")
            Dim dateFilterComboBox As RadComboBox = CType(cell.Controls(0).FindControl("ddlDateFilter"), RadComboBox)
            Dim dateFrom As RadDatePicker = CType(dateFilterComboBox.SelectedItem.FindControl("RadDatePickerFrom"), RadDatePicker)
            Dim dateTo As RadDatePicker = CType(dateFilterComboBox.SelectedItem.FindControl("RadDatePickerTo"), RadDatePicker)
  
        End If
  
    End Sub


dateFrom and dateTo show "Nothing"

any ideas? I want to be able to obtain the dates the user has selected.
Pavlina
Telerik team
 answered on 05 Apr 2012
1 answer
78 views
Hi.
using RadControls I believe - how can I get the filter type chosen by the user on clientside, so I can do a filter based upon that.
We hit a problem with date filtering so if we do an Equals, it will not find the date since the time is not considered when performing the filtering.

Example:

telerik:GridDateTimeColumn FilterControlWidth="60px" AllowFiltering="true" AutoPostBackOnFilter="false"
                        CurrentFilterFunction="Contains" HeaderStyle-HorizontalAlign="Center" DataField="DateTime"
                        HeaderText="Date" SortExpression="DateTime" ShowFilterIcon="true" UniqueName="DateTime"
                        PickerType="DatePicker" DataFormatString="{0:g}" DataType="System.DateTime">
                         
                        <HeaderStyle Width="100px" HorizontalAlign="center"></HeaderStyle>
                        <ItemStyle HorizontalAlign="center" Width="100px"></ItemStyle>
                    </telerik:GridDateTimeColumn>


So we have the datetimes showing.
But at this point, how can I intercept the filtering on the clientside, so I can then also get the input they have entered to filter textbox/datepicker then append say "00:00:00" to that value, finally doing the filter.

how can I do this?
Pavlina
Telerik team
 answered on 05 Apr 2012
1 answer
109 views
Using RadControls I believe.
We have a DateTimePicker and need to do custom filtering on Date only.
I have implemented the code on the ItemCommand event and then I filter a dataset and then finally set the datasource to the grid and bind. I know there are results in there but the grid shows "no results"

any ideas?
<telerik:GridDateTimeColumn FilterControlWidth="60px" AllowFiltering="true" AutoPostBackOnFilter="false"
                        CurrentFilterFunction="Contains" HeaderStyle-HorizontalAlign="Center" DataField="DateTime"
                        HeaderText="Date" SortExpression="DateTime" ShowFilterIcon="true" UniqueName="DateTime"
                        PickerType="DatePicker" DataFormatString="{0:g}" DataType="System.DateTime">
                         
                        <HeaderStyle Width="100px" HorizontalAlign="center"></HeaderStyle>
                        <ItemStyle HorizontalAlign="center" Width="100px"></ItemStyle>
                         
                    </telerik:GridDateTimeColumn>


Code:

Protected Sub grdShiftObservation_OnItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles grdShiftObservation.ItemCommand
 
        If e.CommandName = RadGrid.FilterCommandName Then
 
            Dim filterPair As Pair = DirectCast(e.CommandArgument, Pair)
 
            Select Case filterPair.Second.ToString()
                Case "DateTime"
                    Dim filterOption As String = CType(e.CommandArgument, Pair).First
 
                    Dim filterItem As GridFilteringItem = CType(e.Item, GridFilteringItem)
                    Dim currentPattern As String = CType(filterItem(CType(e.CommandArgument, Pair).Second).Controls(0), RadDatePicker).SelectedDate
 
                    If Not String.IsNullOrEmpty(currentPattern) Then
                        Dim dt As DateTime = Convert.ToDateTime(currentPattern)
 
                        Dim dtFromString As String = dt.ToString("MM/dd/yyyy") & " 00:00:00" ' i.e the date they selected in the picker
                        Dim dtToString As String = dt.AddDays(1).ToString("MM/dd/yyyy") & " 00:00:00"
 
                        Dim filterPatternAssist As String = String.Empty
                        Dim dateColumn As GridBoundColumn = CType(e.Item.OwnerTableView.GetColumnSafe("DateTime"), GridBoundColumn)
 
                        Select Case filterOption
                            Case "EqualTo"
                                dtFromString = "DateTime >= #" & dtFromString & "# AND DateTime < #" & dtToString & "#"
                                dateColumn.CurrentFilterFunction = GridKnownFunction.EqualTo
                            Case "NotEqualTo"
                                dtFromString = "Not DateTime = #" & dtFromString & "#"
                                dateColumn.CurrentFilterFunction = GridKnownFunction.NotEqualTo
                            Case "GreaterThan"
                                dtFromString = "DateTime > #" & dtFromString & "#"
                                dateColumn.CurrentFilterFunction = GridKnownFunction.GreaterThan
                            Case "LessThan"
                                dtFromString = "DateTime < #" & dtFromString & "#"
                                dateColumn.CurrentFilterFunction = GridKnownFunction.LessThan
                            Case "GreaterThanOrEqualTo"
                                dtFromString = "DateTime >= #" & dtFromString & "#"
                                dateColumn.CurrentFilterFunction = GridKnownFunction.GreaterThanOrEqualTo
                            Case "LessThanOrEqualTo"
                                dtFromString = "DateTime <= #" & dtFromString & "#"
                                dateColumn.CurrentFilterFunction = GridKnownFunction.LessThanOrEqualTo
                            Case "Between"
                                dtFromString = "#" & dtFromString & "' <= DateTime AND DateTime <= #" & filterPatternAssist & "#"
                                dateColumn.CurrentFilterFunction = GridKnownFunction.Between
                            Case "NoFilter"
                                dtFromString = String.Empty
                                dateColumn.CurrentFilterFunction = GridKnownFunction.NoFilter
                            Case "NotBetween"
                                dtFromString = "DateTime <= #" & dtFromString & "' OR DateTime >= #" & filterPatternAssist & "#"
                                dateColumn.CurrentFilterFunction = GridKnownFunction.NotBetween
                            Case "IsNull"
                            Case "NotIsNull"
                            Case "Contains"
                                dtFromString = String.Empty
                                dateColumn.CurrentFilterFunction = GridKnownFunction.NoFilter
                        End Select
 
                        FilterGrid(dtFromString)
 
                    End If
            End Select
 
        End If
 
    End Sub
 
 
    Private Sub FilterGrid(ByVal strFilter As String)
        Dim ds As DataSet = GetData()
 
        Dim dvFilter As DataView = ds.Tables(0).DefaultView
        dvFilter.RowFilter = strFilter
 
        grdShiftObservation.DataSource = dvFilter.ToTable()
        grdShiftObservation.DataBind()
    End Sub


I know dvFilter.ToTable() at this point shows me say 5 rows filtered but when the grid is displayed, it shows no results.

what am I doing wrong? How else can I show the filtered results? I am trying to fix lack of support on the control which does not filter datetime values with date only specified hence the customisation above.
Pavlina
Telerik team
 answered on 05 Apr 2012
4 answers
179 views
I've implemented the solution described here already: http://www.telerik.com/help/aspnet-ajax/grid-resizing-in-splitter.html.

However there are a number of drawbacks.  Are there any other options for implementing a resizable RadGrid?
msigman
Top achievements
Rank 2
 answered on 05 Apr 2012
9 answers
249 views
Hi,
Is there a way to trap double click event on server-side event? I need to trap single click and double click to make a different action depending on what event is called.

Thank you!
Peter
Telerik team
 answered on 05 Apr 2012
11 answers
669 views
How do I prevent user from making duplicate entries in a given time slot? I am in timeline and resourceview.
Peter
Telerik team
 answered on 05 Apr 2012
1 answer
127 views
is it possible to set 100% height on the panelbar for MultipleExpandedItems. I want a UI style in which i have a panelbar occupying 100% height with multipleexpandeditems mode. There can be 2-3 panelitems inside that and inside each panelitem there would be a treeview control which should also occupy 100% height of that panelitem. In such a way that scrollbars of treeview are visible and not of the panelitem. I tried but somehow 100% was not working. Is this a known limitation or any workarounds exists?
Peter
Telerik team
 answered on 05 Apr 2012
4 answers
159 views
Hi!

We customized the button by modifying the ButtonSprites file with the below CSS. Everything seems to work for the most part, but we can't seem to get access to the image at the right. CustomizedSearchButton.PNG shows the result of the CSS change (using the file ButtonSprites.png as the background.) We did attempt to see where the button is pulling from in the file ButtonSprites2.png -- however, it appears that the right side of the button does not use any part of this file. We did skin the app with the Windows 7 theme, but we want to override the background image.

Is this possible? Where is it pulling the right side of the button from?

Thanks!
Michael

.button .rbSkinnedButton,
.button .rbDecorated,
.button .rbVerticalButton,
.button .rbVerticalButton .rbDecorated,
.button .rbSplitRight,
.button .rbSplitLeft
{
    background: #EBEFF3 url('/Images/ButtonSprites.png') no-repeat 0px !important;
}
Bozhidar
Telerik team
 answered on 05 Apr 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?