I noticed that when navigating an ASP.Net web site the nodes in the TreeView always expand.
Is there a setting or attribute we can include in the markup that will keep the TreeView nodes collapsed until the user expands them?
Maybe something is needed to be added to the code-behind file?
Yes there is, it's called ExpandDepth
ExpandDepth - Gets or sets the number of levels that are expanded when a TreeView control is displayed for the first time.
If you want all the nodes, including the root, to be collapsed just set it to 0
<asp:TreeView ExpandDepth="0" ...
I don't think you can do this in the markup. But it is possible in code - behind. Check out this link for some sample code: Collapse all open nodes.
I'm pretty sure that an app I wrote a few years collapses the entire tree with one line of code (like you we found that it kept opening up every post back). If this link doesn't work I will post the code I used tomorrow.
The one line of code I was looking for is
tv.CollapseAll();
Related
I have a requirement like for the drop down as shown. Could any one help me in achieving this.
Briefing:
On click of the button a pane should be opened which contains rows and columns containing text, on click of it appropriate action need to take place. The source can be dynamic too....
There are many techniques for acheiving this design. You could do it purely with html and css by having an image that looks like a dropdown popup an absolutely positioned div underneath. Or you could use the asp.net ajax control toolkit control called "PopupControl" that essentially abstracts all the html/css away allowing you to just specify a target panel. There are also various jquery plugins, here is one from abeatifulsite.
I have a page using a Treeview server control like so:
<asp:TreeView ID="uxTreeView" ShowExpandCollapse="True" ShowCheckBoxes="All" runat="server"></asp:TreeView>
What I expect to have happen is my treeview should render a series of checkboxes, with the first level having a plus sign (+) to expand it, and then a minus sign (-) when it's expanded to collapse it.
For some reason, I'm not seeing the expand/collapse links. I can see there's a parent and a child node, and they're properly nested, but the expand/collapse links aren't showing.
Has anyone seen this before? In the past this hasn't been an issue - dragging and dropping the control onto a page has worked fine. I've inspected the elements with Firebug, and I didn't see any CSS that would hide the expand/collapse links.
UPDATE
I've found there's an ImageSet property on the treeview - now my treeview is actually adding the arrows for the various nodes indicating whether they're expanded or collapsed. Is it possible to style the individual cells in the outputted table? (It looks like this would be a lot of work)
Did you by chance specify custom images, perhaps incorrectly, for the expand and collapse elements?
I have a generic function to build rows of controls (each row comprising of sliders, radio buttons, reset buttons, text display) etc, and some functionality to change underlying data based on these
As I didn't want to write specific code for each row, I had code written by which I can detect the row on which there has been a mouseevent, and though the row access each individual control
The hierarchy used is titleWindow (part of popup)->skinnable container->HGroup->control
When I trace for a radiobutton, I get the path as follows Electric_Modify.TitleWindowSkin2620._TitleWindowSkin_Group1.contents.contentGroup.0.RadioButton2645
The '0' before the radioButton stands for the first Hgroup id->named as 0
I tried accessing the radio button as follows- 5th element in the HGroup
((this.contentGroup.getChildAt(row)as Group).getChildAt(4) as RadioButton).enabled=false;
and get a message "Cannot access a property or method of a null object reference" on this line. How should I navigate the hierarchy to reach the element?
You should be using getElementAt(...) and not getChildAt(...).
The get element functions represent a "higher level" element hierarchy which is needed to make skinning easier.
((this.getElementAt(row) as IVisualElementContainer).getElementAt(4) as RadioButton).enabled = false;
It should look something like that, but the exact hierarchy depends on what's in your app.
#drkstr
Thanks for your input... I thought of an alternate approach that worked for me...I mapped out the parent of the HGroup via
parent1=hgrp.parent; and then referenced these buttons as follows
((parent1.getChildAt(row)as Group).getChildAt(4) as RadioButton)
This works like a dream...I presume your suggestion would let me jump across the intermediate layers
#J_A_X/ #Constantiner: Thanks for the suggestion. I have no idea why we didn't think through and go down the DataGroup path. Prima facie seems simpler... we got to creating the UI controls in MXML laying out controls serially,and when it came to making it generic, we literally replicated the MXML approach in AS. Started off easy, till it caused problems like above. We will fix this to a better approach, when we upgrade versions. It works for now
How do I use the ASP.NET sitemap control to render stacked horizontal css menus with styled UL/LIs? It seems to only want to do trees or flyouts.
Set up a SiteMapDataSource and point it at your configured SiteMap Provider. Then bind a repeater (or whatever) to the data source. Use the repeater to emit your UL/LI sturcture.
If you need 2 levels (like nested tabs, where the second level tabs are children of the selected tab at the top) then you will need 2 SiteMapDataSources and set the starting node of the second to the selected node of the first.
This is all from memory of when I did this a couple years ago - so it may not be 100% exact.
If you have specific problems after trying it out, post and I will work out more details if needed.
I googled and found this thread:
http://blogs.sqlxml.org/bryantlikes/archive/2006/02/17/4839.aspx
It seems you have to build your own control. I hope it will move you in the right direction.
Guys, I’ve been writing code for 15+ years, but managed to avoid “Web Development” until 3 months ago.
I have inherited a legacy Asp.net application (started in .net 1.1, we’re now on .Net 2.0), it’s the administration tool for our product.
In several places the admin tool simply maintains long lists of values.
The list (could be 200+ items) appear in a GridView (Page A), user clicks an edit button for an item, this brings them to an edit page for the item (Page B) where they can change the value (or values, an item in the list may be associated with several values e.g. name and address and preferred colour, breed of cat . . .)
Currently when the user presses “Save” on Page B, we redirect back to Page A. The page opens at the top of the list, this annoys the user as often several items in sequence will need to be configured together, and the user needs to 1. Remember which item they just edited, 2. scroll down to that item
What I want to do is have the list bring the user back to the item they just edited, as often several items in sequence will need to be configured together.
Fastest Gun Stop . . . and keep reading
Suggestions on the lines of “regroup the items so there are fewer in the list” will be considered unhelpful
Valid points that .Net 3.5 does this automatically, will be considered unhelpful by me (but post them anyway, it may help some other poor fool)
I think I could do this by posting the Id of the edited item when re-loading Page A, and scrolling the grid to this point, however My Question is . . .
Is there a feature to do this that I don’t know about (and what is it)
and/or
What is the accepted way of doing this?
Thanks in advance
B. Worrier
This could be achieved using Anchor Tags.
When you output your elements on Page A, set an anchor tag next to each element like follows:
<a name="#175"></a>
Where this item would be item id 175.
Then when you redirect back to PageA, add a "#175" onto the end of the url
Response.Redirect("PageA.aspx#175");
The simplest way you can do is to pass back an id from PageB in the querystring in the URL while redirecting back to PageA after saving in PageB.
e.g. www.example.com/PageA.aspx?editedId=89
and in PageLoad of PageA, you can check if this is from the editing detail page by examineing whether there is a valid value in HttpContext.Current.QueryStrubg["editedId"],
if there was, it means it is from PageB.
You can use this value to highlight or select the row in the datagrid easily
Fastest Gun Stop . . . and keep reading...
A good control allows you to edit multiple rows at the same time on same page for example on PageA, and save them together. Check you Telerik control for datagrid. You'd love it.