This is a migrated thread and some comments may be shown as answers.

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

1 Answer 75 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Kori
Top achievements
Rank 2
Kori asked on 01 May 2009, 05:11 PM
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.

<telerik:RadComboBox ID="healthNumberCombo" Width="250px" AutoPostBack="true" EmptyMessage="Health Number" AllowCustomText="true" runat="server" HighlightTemplatedItems="true" 
                 EnableLoadOnDemand="true" LoadingMessage="Loading ..." Height="273px" 
                 OnClientItemsRequesting="onItemsRequesting" OnClientItemDataBound="onItemDataBound" 
                 OnClientSelectedIndexChanged="onSelectedIndexChanged"
                <WebServiceSettings Method="GetPatientList" Path="Services/AutoComplete.asmx" /> 
            </telerik:RadComboBox> 
<div id="myTemplate" class="sys-template"
                <div> 
                    <b>Name:&nbsp;</b>{{FullName}}<br /> 
                    <b>DOB:&nbsp;</b>{{BirthDate.format("MM/dd/yyyy")}}<br /> 
                    <b>HC#:&nbsp;</b>{{HealthNumber}} 
                </div>               
            </div> 
function onItemDataBound(sender, eventArgs)  
        { 
            var item = eventArgs.get_item(); 
            var dataItem = eventArgs.get_dataItem(); 
 
            item.get_attributes().setAttribute("hc", dataItem.HealthNumber); 
            item.get_attributes().setAttribute("dob", dataItem.BirthDate); 
             
            item.set_value(dataItem.PatientID); 
 
            dataItem.Index = item.get_index(); 
 
            var template = new Sys.UI.Template($get("myTemplate")); 
            template.instantiateIn(item.get_element(), dataItem); 
        } 
 
function onSelectedIndexChanged(sender, eventArgs) { 
 
                var item = eventArgs.get_item(); 
                sender.set_text(item.get_attributes().getAttribute("hc")); 
 
                var dob = item.get_attributes().getAttribute("dob"); 
                var dobPicker = $find('<%= dobPicker.ClientID %>'); 
                 
                debugger
                if (dobPicker != null) { 
                    dob1.set_selectedDate(dob);  
                } 
            } 
 

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

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 05 May 2009, 02:04 PM
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.
Tags
Calendar
Asked by
Kori
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Share this question
or