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

Client Events Help

1 Answer 70 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Developer
Top achievements
Rank 1
Developer asked on 10 Aug 2015, 02:25 PM

Hello,

I have a RadTreeList cotrol. Within this is a TreeListTemplateColumn.
Inside this I have two DIVs and radbutton configured as a custom toggle.  What I’d like to do is is when the user clicks the toggle button the system hides one div and shows the other.

I’ve had a go at this with little success.  Here is the code for the buttons

 

<telerik:RadButton ID="RadButton2" runat="server" ButtonType="LinkButton" Checked="True"
        Skin="Metro" ToggleType="CustomToggle" OnClientToggleStateChanged="SetVisibility"
        AutoPostBack="False">
        <ToggleStates>
            <telerik:RadButtonToggleState PrimaryIconCssClass="rbToggleCheckboxChecked" Text="Existing" />
            <telerik:RadButtonToggleState PrimaryIconCssClass="rbToggleCheckbox" Text="New" />
        </ToggleStates>
    </telerik:RadButton>

 

And here is the associated JavaScript:

            function SetVisibility(sender, args)
    {
        switch (args.get_currentToggleState().get_text())
        {
            case "Existing":
                showstuff('existing');
                hidestuff('new');
                break;
            case "New":
                showstuff('new');
                hidestuff('existing');
                break;
            default:
                hidestuff('new');
                hidestuff('existing');
                break;
        }
    }
 
    function showstuff(boxid){
   document.getElementById(boxid).style.visibility="visible";
}
  
function hidestuff(boxid){
   document.getElementById(boxid).style.visibility="hidden";
}

 

The problem with this is that is doesn't matter which button (row) within the treelist you click, the only DIVs that get changed are those within the first row.
Any ideas how I can overcome this?

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 12 Aug 2015, 03:08 PM
Hi,

You need to use runat="server" for the divs or define a unique ID depending on the item they are placed in. I've created a sample RadTreeList web site to demonstrate how you can achieve the requested functionality. Please run the attached application and let me know if it helps you.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Developer
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or