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

radcombos and same address option

4 Answers 77 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Joseph
Top achievements
Rank 1
Joseph asked on 03 Feb 2011, 08:22 PM
Hello,

I am capturing 2 sets of addresses, a job site address and a job ship address, and am using radcomboboxes as shown in the related combobox demo.  I am using the comboboxes for city, state, county, zip and country.  I have a checkbox so that if the ship address is the same as the site address one can check the box and the values will be copied from the site address to the ship address.  In addition, I'd like to be able to change the ship address if necessary (after checking the box) by making use of the comboboxes.  I currently have a function for the onclick event of the checkbox called DupAddresses().  Inside the DupAddresses() function I am calling the requestItems event and passing the appropriate data for each combobox. I don't get any error messages, and when I put in javascript alerts and codebehind breakpoints, it looks like the appropriate data is going to the right place. When the checkbox is clicked, I am able to successfully use combobox.set_text to set the appropriate text in the fields, but I have not been able to figure out how to databind the updated combo values to the comboboxes - instead they retain the previous values.  For example, if the original ship city/state was Birmingam/Alabama and the site city/state is Atlanta/Georgia, if I click the checkbox, I can change the ship city/state combo text to show Birmingham/Alabama, but if I click on the ship city combo the list still reflects those cities found in Alabama, not Georgia.  Any ideas/suggestions would be great.

Thanks.

4 Answers, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 09 Feb 2011, 01:54 PM
Hi Joseph,

I've prepared a small example project which is implementing the scenario that you need.
If you still have problem after reviewing this example please do not hesitate to contact us again.

Kind regards,
Dimitar Terziev
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Joseph
Top achievements
Rank 1
answered on 09 Feb 2011, 04:38 PM
Hi Dimitar,

Thank you for your response and the attached example.  I was able to make your example work as provided.  I need to go one step further and be able to copy all of the drop down fields - for example, instead of copying just the continent field, I need to copy the continent, country and city field.  I tested being able to copy the country field in addition to the continent field by modifying the javascript as shown below:

function onCheckChanged() {
               var selectedIndex = continetCombo1.get_selectedIndex();
               var item2 = continetCombo2.get_items().getItem(selectedIndex);
               item2.select();
               var selectedIndex2 = countriesCombo.get_selectedIndex();
               var item3 = countriesCombo2.get_items().getItem(selectedIndex2);
               item3.select();                   
       }

When I run the example I get the following javascript error: Microsoft JScript runtime error: 'undefined' is null or not an object.  This is caught at the item3.select() statement.  I'll continue to play with the example but if you have any suggestions in the meantime that would be great.

Thank you for your help,
Joseph
0
Joseph
Top achievements
Rank 1
answered on 09 Feb 2011, 09:45 PM
Hi Dimitar,

After playing around with the javascript and dropdowns, this is what I've come up with so far that works:
function onCheckChanged() {
            var selectedIndex = continetCombo1.get_selectedIndex();
            var item2 = continetCombo2.get_items().getItem(selectedIndex);
            item2.select();   
            setTimeout("OnCheckChanged1()", 250);   
        }
        function OnCheckChanged1() {
            var selectedIndex2 = countriesCombo.get_selectedIndex();
            var item3 = countriesCombo2.get_items().getItem(selectedIndex2);
            item3.select();
            setTimeout("OnCheckChanged2()", 250);
            return;
        }
        function OnCheckChanged2() {
            var selectedIndex3 = citiesCombo.get_selectedIndex();
            var item4 = citiesCombo2.get_items().getItem(selectedIndex3);
            item4.select();
            return;
        }

I guess the javascript code runs faster than the dropdowns can update, which was resulting in the error message.  This works fine for dropdowns with small lists, but for ones with longer lists I have to increase the delay value in the setTimout() call to avoid getting an error message.  If you have any ideas or different suggestions that would be great.  If you don't I'll mark this thread as answered.

Thank you for your help,
Joseph
0
Dimitar Terziev
Telerik team
answered on 14 Feb 2011, 11:24 AM
Hi Joseph,

You are absolutely right that the javascript function will be executed faster that the combobox is updated. This is normal since the combobox loads item from a database. In your scenario using timeout function is a good approach since you could set the time based on the number of item you are loading into the combobox.

Regards,
Dimitar Terziev
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
ComboBox
Asked by
Joseph
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Joseph
Top achievements
Rank 1
Share this question
or