Showing posts with label item. Show all posts
Showing posts with label item. Show all posts

Monday, March 26, 2012

cascadingdropdowns when only one listitem

I am happily using cascading dropdowns for a three-level stack. In some cases, there is only one item in the generated list apart from the select prompt. Common sense and good design suggests that the one item should be auto-selected but this has not been implemented in the Toolkit.

I tried to implement it by setting the selected attribute (third parameter) to 'true' in the Web service. This worked for the displayed ddl, but the underlying value was not set . Hence the next level in the dropdown failed because no value was supplied.

Is this a bug or am I doing something wrong?

The relevant line in the VB Web Service (PageMethod) is:

values.Add(

New CascadingDropDownNameValue(sCompany, sCompanyId,True))

If I do not use the third parameter, I get the standard result with my Prompt showing in the ddl, and everything working when I actually select the one item.

This sounds like a bug. Could you whip up a quick sample page demonstrating the problem and file the issue at CodePlex?

http://www.codeplex.com/WorkItem/List.aspx?ProjectName=AtlasControlToolkit

Thanks!

Saturday, March 24, 2012

CascadingDropDown Selects Wrong Item on PostBack

I have a page where the cascadingdropdown is selecting the wrong item in the list on postback. I can verify that the JavaScript created by the AJAX controls says to select item "5::Description Here" yet item 4 gets selected when the page loads after post back. So you select the parent value, then the child, then click a button that does a postback (in this case a search) and when the two drop downs load the first one is selected correctly and the 2nd one, the cascading drop down, has selected the item above the correct item. If I continue to submit the form over and over the selected item just keeps moving up one spot. I attemted to remove any appended items, in my case one that says "-- Select --", as well as the prompttext as it appears to be an "index" issue, but that didn't solve the problem. I have the exact same dropdown fields on another form where they work just fine on postback. I don't want to post the whole page but here are the dropdowns in question. OfficeLocation is the parent and RateSchedule is the child.

<asp:DropDownListID="drpOfficeLocation"runat="server"AppendDataBoundItems="True"DataSourceID="srcOfficeLocations"DataTextField="Value"DataValueField="ID"Width="150px"EnableViewState="True">

<asp:ListItemValue="">-- Select --</asp:ListItem>

</asp:DropDownList>

<asp:DropDownListID="drpRateSchedule"runat="server"AppendDataBoundItems="True"

DataTextField="Value"DataValueField="ID"EnableViewState="False">

</asp:DropDownList>

<cc1:cascadingdropdownid="ccRates"runat="server"category="Location"

loadingtext="Loading Rates..."parentcontrolid="drpOfficeLocation"

servicemethod="GetRateResults"servicepath="JobAJAX.asmx"targetcontrolid="drpRateSchedule"></cc1:cascadingdropdown>

You simply won't believe what I found to be the problem. My controls are in a table that has style="display:none;" and you click an image to show the table. Removing this "display:none" from the table allowed the JS to select the correct item in the dropdown. I added it back and it selected the wrong one again. I can't make any sense of this but that's the problem.

Wednesday, March 21, 2012

CascadingDropDown is there any way not to show PromptText

I'm using CascadingDropDown and I can't figure out how to get rid of first item (PromptText) in dropdown. I know that my second dropdown always contains at least one item, so I don't want to show PromtText at all and I want to select first item by default. I tried not to use PromptText in CascadingDropDown, but DropDown is always disabled in this case. Is there any way to do what I want?

See work item8672. It discusses not having to require PromptText.