Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
110
Issues with ClientEvents-SelectionChanged, esp. when backspacing mid word
posted

I have a WebDropDown on my page:

 

<ig:WebDropDown ID="ddlRelationId" runat="server"  EnableCustomValues="false" EnableCustomValueSelection="false" DropDownContainerWidth="249px" CssClass="sysReq" EnableAnimations="false" ClientEvents-SelectionChanged="indexChanging1" ClientEvents-Initialize="indexChanging1" />

1. EnableCustomValues only works if I set it in the code behind, which is a minor issue, but... thought I'd point it out.

 

Anyway, I have this script, which essentially works:

function indexChanging1(sender, eventArgs) {
        var selectedValue = sender.get_selectedItem().get_value();
        if (selectedValue == 14) {
            $('#fieldsetChild').show();
        }
        else if (selectedValue == 15) {
            $('#fieldsetChild').show();
        }
        else {
            $('#fieldsetChild').hide();
        }
    }

If I set the EnableCustomValues = False on the back end, then it won't let me type characters that don't make sense, which is good... but two strange things happen.

1. If I select the end of the field after a good value is in there, and the script has run properly, and hold down shift and hit home to select all of the text, it unselects the selected item, and selects the empty item I've inserted at the top of the list of dropdown items.

2. If I go into the middle of the current value and backspace, it fires off an error because the selected item is null (on var selectedValue = sender.get_selectedItem().get_value();).

 

The first issue is annoying, and the second issue is quite problematic... both are issues considering the stuff that our user base tends to get up to.

 

Help?

 

Parents
No Data
Reply
  • 110
    posted

    Also, the null selection causes issues on the first visit to the page if no item is selected (e.g. when you are visiting to make a new record), so I need some way to check if there is no selected item for the dropdown, and if there is not  a selected record, skip the code... but I'm hazy on the syntax for that - a check that sender.get_selectedItem is null...

Children