Showing posts with label accordion. Show all posts
Showing posts with label accordion. Show all posts

Wednesday, March 28, 2012

Change visible accordion panel client side

How can I change which accordion panel is visible using javascript?

Try this ..

function OpenPane(paneIndex) {var accHost = $get(<AccordionID>).AccordionBehavior ;accHost.set_SelectedIndex( paneIndex );}The "AccordionBehavior" lets you access the methods as you would do with a BehaviorID.
Please mark my reply as an answer if this solves the issue

Thanks for the response. I added alerts to the javascript as shown below, because nothing was happening. The first alert works, but the second alert is never displayed.

function

OpenPane(paneIndex)

{

alert(paneIndex);

var accHost = $get('Accordion1').AccordionBehavior;

alert(accHost);

accHost.set_SelectedIndex( paneIndex );

}

What's wrong?


Hi,

If you dont get the second alert , you should have an error at the line $get('Accordion1').AccordionBehavior.

Can you check if $get('Accordion1') is a valid object .

change the code to be

functionOpenPane(paneIndex)

{

alert(paneIndex);

var accord = $get('Accordion1');

var accHost ;

if( accord != null)

{

accHost = accord.AccordionBehavior;

}

alert( accord );

alert(accHost);

accHost.set_SelectedIndex( paneIndex );

}

and also , what is the ID of the Accordion You are using , "Accordion1" ?


That code should work. If you're not getting to the second alert(), my guess is that "$get('Accordion1')" is returning null. Are you sure you have the correct ID of your Accordion?

If "Accordion1" is the server ID, you probably want: $get('<%= Accordion1.ClientID %>') in case the client ID is different (because it's inside a naming container, for example).


Excellent. Between Phanatic and Steve it is now working properly. Thanks very much, both of you.

Hi,
Need your help.
I am using the Accordion Panel. I have tried your code, but unfortunately couldnt get it to work.

I am getting error in accessing the property AccordionBehavior.

"accHost = accord.AccordionBehavior;"
accHostalways contain undefined value.

any help would be apprecitated..

Thanks in advance.

--Saurabh

.

change image on accordion click

I have an image on my accordion header.

I want to change that image when somebody expands the header and show the original image when the header is collapsed.

Can somebody help me ?

Take a look at bug8730 and let us know if the fix helps you. You can download the latest non-release version from thesource code tab on the codeplex site.

Saturday, March 24, 2012

CascadingDropDown within an Accordion

I have a functioning CDD that I add dynamically to the page during ON_LOAD. I also have a new Accordion that I declare in the ASCX file. Both of these work fine until I try to put the CDD inside the Accordion. I get the following error:

Couldn't get extender properties on extender . Make sure the ID is spelled correctly and the control is on the page.

With the CDD inside the Accordion, I find the dropdown id using:

tempControl = MyAccordion.FindControl("ddlClientCompany")

item1.TargetControlID = tempControl.UniqueID

When I step thru the code with VS I can see that the control is found and an ID is passed in. But an error is thrown:o my question is: 1) is this a bug? 2) What is the correct procedure to include a CDD within the Accordion?

Here is my full code for when I add the CDD (this works fine outside of the Accordion)...

Dim tempExtenderAs AtlasControlToolkit.CascadingDropDown =New AtlasControlToolkit.CascadingDropDown()

Dim item1As AtlasControlToolkit.CascadingDropDownProperties =New AtlasControlToolkit.CascadingDropDownProperties()

item1.Category ="clientCompanyID"

If item1.Category =""Then item1.Category ="none"

item1.DefaultCompany = bu.default_company_id

item1.PromptText ="-- Select Company --"

item1.ServiceMethod ="GetClientCompanies"

item1.ServicePath ="~/buService.asmx"

Dim tempControlAs DropDownList

tempControl = MyAccordion.FindControl("ddlClientCompany")

item1.TargetControlID = tempControl.UniqueID

tempExtender.TargetProperties.Add(item1)

I'll defer to Ted as Accordion expert, but I'm thinking you don't want UniqueID in "item1.TargetControlID = tempControl.UniqueID". I'd try just ID instead.

Thanks for your reply David,

First let me say that I think Atlas rocks and and glad to be part of the CTP, pain and all. Secondly, I am very excited about how Atlas has effect my application interface design- cool ideas with low overhead to implement...nice job!

I did try some combinations that included the ID instead of the UniqueID...but they didnt work.

Although I never got it to work by adding the Extender dynamically, I was able to get it to work when I fully declared the CDD within the ASCX page. This is a work around in my mind and would be very interested in finding out how to do this properly dynamically.

I am also unable to get the SELECTED_VALUE of the CDD from within the Accordion. I am forced to just parse the query object like so.

' lets try to checkout the form values manually

Dim tempDDLClientCompanyAs DropDownList = MyAccordion.FindControl("ddlClientCompany")

Dim tempDDLClientNameAs DropDownList = MyAccordion.FindControl("ddlClientName")

' This is still not returning a value

'client_name = sec.ScrubData(tempDDLClientCompany.SelectedValue)

'manager_name = sec.ScrubData(tempDDLClientName.SelectedValue)

Dim tempClientCompanyID = tempDDLClientCompany.UniqueID

Dim tempClientNameID = tempDDLClientName.UniqueID

Try

Dim formsCountAsInteger = (Request.Form.Count) - 1

If formsCount <= 0ThenExitTry

Dim countAsInteger = 0

' 1) Grab the values from the request for company and client name

Dim tempField, tempValueAsString

' This is not zero based because the forms collection is not zero based.

For count = 1To formsCount

tempValue =CType(Request.Form.Item(count),String)

tempField =CType(Request.Form.GetKey(count),String)

If tempField = tempClientCompanyIDThen

client_name = tempValue

EndIf

If tempField = tempClientNameIDThen

manager_name = tempValue

EndIf

Next

Catch exAs Exception

EndTry


Hi Matthew,

Are you adding the extender right next to the drop down? If they're in different naming containers than that might explain why it can't find it (i.e. even though you pass in UniqueID, it still wouldn't be able to find a match if it was only looking in its own naming container).

Thanks,
Ted


Thanks for the reply Ted,

Let me try to recall that issue...it was a day or so ago and I have since gotten my head around other items, but I believe I tried several places for the extender. 1) Outside the Accordion, and 2) inside the Accordion within the same pane as the CDD if that is what you mean. I'll pull the code tomorrow and see where I left off. cheers,