<telerik:GridDateTimeColumn DataField="AssignDate" DataFormatString="{0:MM/dd/yyyy hh:mm tt}" HeaderText="Assign Date" PickerType="DatePicker" SortExpression="AssignDate" UniqueName="AssignDate" />if (filter.Contains("[AssignDate]")) { int index = filter.IndexOf("([AssignDate]"); int firstQuote = filter.IndexOf("'", index); int lastQuote = filter.IndexOf("'", firstQuote + 1); string stringToExcise = filter.Substring(index, lastQuote - index + 2); string dateToParse = filter.Substring(firstQuote + 1, lastQuote - firstQuote - 1); DateTime dateTime = DateTime.Parse(dateToParse); assignDate = "(convert(varchar(10), [AssignDate], 101) = '" + dateTime.Month.ToString("0#") + "/" + dateTime.Day.ToString("0#") + "/" + dateTime.Year + "')"; }
<telerik:GridDateTimeColumn datafield="ExportedDate" DataFormatString="{0:MM/dd/yyyy}" datatype="System.DateTime"
headertext="Exported" sortexpression="ExportedDate" uniquename="EXPORTED" FilterControlWidth="75px">
<HeaderStyle HorizontalAlign="Center" Width="90px"/>
<ItemStyle HorizontalAlign="Right" Width="90px"/>
</telerik:GridDateTimeColumn>
What I have found is that the date will not work correctly on fields unless the data coming from the database has the time essentially set to 00:00:00. All the filtering is done by the specified date with the time set to midnight.
For example: if my date field from the database is 3/25/2009 06:30:12 and I'm filtering on the date 3/25/2009, then the following results ocurr:
Comparison Expected Result Actual Result
-------------------------- ----------------------- --------------------
EqualTo Match No match
NotEqualTo No Match Match
GreaterThan No Match Match
LessThan No Match No Match
GreaterThanOrEqualTo Match Match
LessThanOrEqualTo Match No Match
As you can see, only 2 comparisons return results as expected. It all stems around the issue with the time component being used in the comparison.
Work arounds include adding custom filtering, changing every database access procedure or call to remove the time component in the results, and limiting the filter functions to only what works.
None are very attractive when considering the extent of work involved. This system that the Telerik controls are used was initially developed 10 years ag0 and has grown to have at one site alone, 300,000 registered users, hundreds of web pages, thousands of queries, and, needless to say, an extremely large amount of accumulated data.
I believe I shouldn't have to add code to make the date filter work as logically expected. The filtering logic should automatically strip off the TimeOfDay and not be used in the comparisons. Because the System.DateTime has a resolution down to the milliseconds, anyone searching for any equality based on the date will not find a match. This is especially true when picking a date from the calendar icon or when typing in a date; you do not specifiy the time and it is implied to be midnight.
Any assistance, comments, or improvements is greatly appreciated.
Ed Lamprecht
Public Class TempComboBox Inherits RadComboBox Const BACK_SPACE = "8" Private Sub CompanyInfoComboBox_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init Dim oHeaderTemplate Dim oItemTemplate Me.Height = 200 Me.EnableTextSelection = True Me.MarkFirstMatch = False Me.EnableViewState = True Me.DropDownWidth = 500 Me.OnClientDropDownOpening = "DropDownOpening" Me.EmptyMessage = "Type Code" Me.EnableLoadOnDemand = True Me.ShowMoreResultsBox = False Me.ShowDropDownOnTextboxClick = True Me.HighlightTemplatedItems = True Me.OnClientItemsRequested = "HighlightItem" Me.OnClientItemsRequesting = "HandleKeyPress" Me.OnClientKeyPressing = "HandleTab" Me.OnClientFocus = "HandleOnFocus" Me.CloseDropDownOnBlur = True Me.ChangeTextOnKeyBoardNavigation = True Page.ClientScript.RegisterStartupScript(Me.GetType, "TelerikHandleKeyPressScript", TelerikHandleKeyPressScript()) Page.ClientScript.RegisterStartupScript(Me.GetType, "TelerikHandleTabScript", TelerikHandleTabScript()) Page.ClientScript.RegisterStartupScript(Me.GetType, "TelerikDropDownOpeningScript", TelerikDropDownOpeningScript()) Page.ClientScript.RegisterStartupScript(Me.GetType, "TelerikHandleOnFocusScript", TelerikHandleOnFocusScript()) Page.ClientScript.RegisterStartupScript(Me.GetType, "TelerikHighlightItemScript", TelerikHighlightItemScript()) AddHandler Me.ItemsRequested, AddressOf RadComboBox_ItemsRequested oHeaderTemplate = New MasterHeaderTemplate oItemTemplate = New MasterItemTemplate Me.Width = 75 Me.HeaderTemplate = oHeaderTemplate Me.ItemTemplate = oItemTemplate End Sub Function TelerikHighlightItemScript() As String Dim sJscript As String = "<script language=""javascript""> " & _ " function HighlightItem(combo,e){" & _ " var item=combo.get_items().getItem(0); " & _ " if (item){ " & _ " if (item.get_value() != '0'){ " & _ " item.highlight() ; " & _ " } } " & _ " } </script>" Return sJscript End Function Function TelerikDropDownOpeningScript() As String Dim sJscript As String = "<script language=""javascript""> " & _ " function DropDownOpening(combo,e){" & _ " combo.requestItems(combo.get_text(), false); " & _ " } </script>" Return sJscript End Function Function TelerikHandleTabScript() As String Dim sJscript As String = "<script language=""javascript""> " & _ " function HandleTab(combo,e){" & _ " if (event.keyCode == 9) { " & _ " combo.hideDropDown(); " & _ " if (combo.get_value() == ''){" & _ " if (combo.get_items().get_count() > 0){" & _ " combo.set_value(combo.get_text()); } else { combo.set_value(combo.get_text()); } } }" & _ " } </script>" Return sJscript End Function Function TelerikHandleOnFocusScript() As String Dim sJscript As String = "<script language=""javascript""> " & _ " function HandleOnFocus(combo,e){" & _ " var attrib = combo.get_attributes().getAttribute('OriginalFieldID'); " & _ " var firstCombo = $find('FilterType_'+attrib+''); " & _ " if (firstCombo){ " & _ " combo.requestItems(firstCombo.get_value()+'_FilterType', false); } " & _ " } </script>" Return sJscript End Function Function TelerikHandleKeyPressScript() As String Dim sJscript As String = "<script language=""javascript""> " & _ " function HandleKeyPress(combo,e){" & _ " try {if (keypressed == 9) { combo.hideDropDown(); " & _ " }} catch(e) {}" & _ " try {if (keypressed == 8) { var context = e.get_context();" & _ " context[""keyPressed""] = keypressed+''; }} catch(e) {}" & _ " } </script>" Return sJscript End Function Protected Sub RadComboBox_ItemsRequested(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) If (e.Context.TryGetValue("keyPressed", BACK_SPACE)) Then 'do nothing Else If e.Text.Trim.Length > 3 Then GetDataIntoCombo(e.Text) End If End If End Sub Public Sub GetDataIntoCombo(ByVal txtCode As String) Dim dt As DataTable = GetComboBoxDataFROMDATABASE(txtCode) If dt.Rows.Count = 0 Then Dim item As New RadComboBoxItem() Dim hl As New HyperLink() hl.ID = "hl" hl.Text = " There were no matches. Please click on this link for further information." item.Value = "0" item.DataBind() Me.Items.Add(item) item.DataBind() ElseIf dt.Rows.Count < 51 Then SetDisplayItemsForRefInfo(dt) Dim item As New RadComboBoxItem() item.Text = String.Empty item.Value = "0" Me.Items.Add(item) Else Dim item As New RadComboBoxItem() item.Text = "Too many codes have been found. Please enter more characters." item.Value = "0" Me.Items.Add(item) End If Me.DataBind() End Sub Private Sub SetDisplayItemsForRefInfo(ByVal dt As DataTable) For Each dataRow As DataRow In dt.Rows Dim item As New RadComboBoxItem() Dim Code As String = String.Empty item.Text = DirectCast(dataRow("Code"), String) item.Value = dataRow("Code").ToString() Dim Name As String = String.Empty Try Name = DirectCast(dataRow("Name"), String) Code = DirectCast(dataRow("Code"), String) Catch ex As Exception End Try item.Attributes.Add("Code", Code.ToString) item.Attributes.Add("Name", Name.ToString()) Me.Items.Add(item) item.DataBind() Next End Sub Private Function GetComboBoxDataFROMDATABASE(ByVal UserText As String) As DataTable Try 'code to get from DB Return New DataTable Catch ex As Exception Return Nothing End Try End Function End Class
An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
|
[InvalidCastException: Unable to cast object of type 'ItemTemplateLinks' to type 'System.Web.UI.IBindableTemplate'.] |
Hi, I am trying to make my splitter fit into the div that i specify.
Following code works perfect when placed inside aspx, but the UI changes (radSplitter now takes default width and height of 400px) when the same code is places inside the ascx.
I am not sure, why ? Ideally, the RadSplitter should use the absolute dimensions of the container to set its width and height.
Why should i bother to set the dimensions for all parent containers ?? The moment i specify absolute values for the container, the child controls should use those values.
Please correct me if my understanding is wrong.
<div style="width: 700px; height: 500px; border: 2px solid orange;"><asp:ScriptManager ID="ScriptManager1" runat="server" /> <telerik:RadSplitter ID="SplitterHorizontal" runat="server" height="100%" width="100%" Scrolling="None"> <telerik:RadPane ID="LeftPane" runat="server" width="30%"> <telerik:RadSplitter ID="VerticalSplitter" Orientation="Horizontal" runat="server"> <telerik:RadPane ID="LeftTopPane" runat="server" style="height:50%"> </telerik:RadPane> <telerik:RadSplitBar ID="HorizontalSplitBar" runat="server" CollapseMode="Forward" /> <telerik:RadPane ID="LeftBottomPane" runat="server" height="50%" > </telerik:RadPane> </telerik:RadSplitter> </telerik:RadPane> <telerik:RadSplitBar ID="VerticalSplitBar" runat="server" CollapseMode="Forward" /> <telerik:RadPane ID="RightPane" runat="server" width="70%"> </telerik:RadPane> </telerik:RadSplitter></div>