Setting Date Issue with DatePicker and LoD ComboBox (LINQ on Demand)

2 posts, 0 answers
  1. kfrancis
    kfrancis avatar
    69 posts
    Member since:
    Dec 2008

    Posted 01 May 2009 Link to this post

    So, 

    I'm having a bit of an issue trying to select the date the user selected from a "load on demand" client-side bound combobox.

    1 <telerik:RadComboBox ID="healthNumberCombo" Width="250px" AutoPostBack="true" EmptyMessage="Health Number" AllowCustomText="true" runat="server" HighlightTemplatedItems="true" 
    2                  EnableLoadOnDemand="true" LoadingMessage="Loading ..." Height="273px" 
    3                  OnClientItemsRequesting="onItemsRequesting" OnClientItemDataBound="onItemDataBound" 
    4                  OnClientSelectedIndexChanged="onSelectedIndexChanged"
    5                 <WebServiceSettings Method="GetPatientList" Path="Services/AutoComplete.asmx" /> 
    6             </telerik:RadComboBox> 
    1 <div id="myTemplate" class="sys-template"
    2                 <div> 
    3                     <b>Name:&nbsp;</b>{{FullName}}<br /> 
    4                     <b>DOB:&nbsp;</b>{{BirthDate.format("MM/dd/yyyy")}}<br /> 
    5                     <b>HC#:&nbsp;</b>{{HealthNumber}} 
    6                 </div>               
    7             </div> 
    1 function onItemDataBound(sender, eventArgs)  
    2         { 
    3             var item = eventArgs.get_item(); 
    4             var dataItem = eventArgs.get_dataItem(); 
    5  
    6             item.get_attributes().setAttribute("hc", dataItem.HealthNumber); 
    7             item.get_attributes().setAttribute("dob", dataItem.BirthDate); 
    8              
    9             item.set_value(dataItem.PatientID); 
    10  
    11             dataItem.Index = item.get_index(); 
    12  
    13             var template = new Sys.UI.Template($get("myTemplate")); 
    14             template.instantiateIn(item.get_element(), dataItem); 
    15         } 
    16  
    17 function onSelectedIndexChanged(sender, eventArgs) { 
    18  
    19                 var item = eventArgs.get_item(); 
    20                 sender.set_text(item.get_attributes().getAttribute("hc")); 
    21  
    22                 var dob = item.get_attributes().getAttribute("dob"); 
    23                 var dobPicker = $find('<%= dobPicker.ClientID %>'); 
    24                  
    25                 debugger
    26                 if (dobPicker != null) { 
    27                     dob1.set_selectedDate(dob);  
    28                 } 
    29             } 
    30  

    And all that happens is the date picker displays the warning image (like incorrect input) and nothing will display. The combobox value dataItem.BirthDate comes from a webservice which uses LINQ to get the data from a Patient table, where BirthDate is of type DateTime (which is why I specify the format in the template, or it'll display everything in the object (date and time and timezone, etc etc)

    I've tried creating a new date object, i've tried splitting the date into a 3 part array as I read somewhere .. nothing works.

    Telerik 2009.1.402.35
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 05 May 2009 Link to this post

    Hi Kori,

    What is displayed when you alert your date? If it is a string you need to use the JavaScriptSerializer and deserialize it as a valid date object.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top