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?
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...
I have gotten around the issue with the null value by putting it into a try-catch...
It seems that if you hit home or end, it goes to the first/last item in the dropdown, and that's why it 'deselects' - it has selected the blank item. If I hit 'End', it selects the last item (but in both cases does NOT change the currentvalue, so that's an issue).
The main problem now seems to be the following... I have a dropdown:
<ig:WebDropDown ID="ddlStatusId" runat="server" EnableAppStyling="True" StyleSetName="Default" EnableAnimations="false" DropDownContainerHeight="330px" DropDownContainerWidth="172px" />
In code behind, I have set:
ddlStatusId.EnableCustomValues = False ddlStatusId.EnableCustomValueSelection = False ddlStatusId.AutoPostBackFlags.ValueChanged = Infragistics.Web.UI.AutoPostBackFlag.Off ddlStatusId.AutoPostBackFlags.SelectionChanged = Infragistics.Web.UI.AutoPostBackFlag.On
If I start typing in the dropdown, and it selects an item, I get a javascript error:
Error: 'this._container.style' is null or not an object