 |
|
|
 |
|
 |
Guys .. desperately in need of ExpandAll JavaScript. I am strugling on it for the past one month .. Help me !!!!!. It's going to great help...
Aks
|
|
|
|
 |
|
 |
Aks ,
Here is JavaScript for ExpandAll/Collapse All
How to use JavaScript:
Get hold of the number of levels . Navigate to each level and set div tags visibility.
Set Button Text accordingly...
Code :
function ExpandCollapseAll()
{
var div,img;
var sTGCount = window.parent.first.treeForm.hdnArrTG.value.split("/");
try{
for( i = 0; i < parseInt(window.parent.first.treeForm.hdnTotal.value) ; i++)
{
var maindiv = '_treeWeb:element' + i;
var mainimg = '_treeWeb_element' + i + 'img';
div=document.getElementById(maindiv);
img=document.getElementById(mainimg);
if (window.parent.first.treeForm.btnExpand.value == "Expand All")
{
div.style.display = '';
img.src='./Images/ElementMinus.jpg';
}
else
{
div.style.display = 'none';
img.src='./Images/ElementPlus.jpg';
}
for( j = 0 ; j < sTGCount[i] ; j++)
{
try
{
maindiv = '_treeWeb:element' + i +':element' + j;
mainimg = '_treeWeb_element' + i + '_element' + j +'img';
div=document.getElementById(maindiv);
img=document.getElementById(mainimg);
if (window.parent.first.treeForm.btnExpand.value == "Expand All")
{
div.style.display = '';
img.src='./Images/ElementMinus.jpg';
}
else
{
div.style.display = 'none';
img.src='./Images/ElementPlus.jpg';
}
}catch(e){}
}
}
}catch(e){}
if(window.parent.first.treeForm.btnExpand.value == "Expand All")
window.parent.first.treeForm.btnExpand.value = "Collapse All";
else
window.parent.first.treeForm.btnExpand.value = "Expand All";
}
Happy Coding
Kusal
|
|
|
|
 |
|
 |
any body is having javascript to collaspse and expand onclck if +/- symbols. This improves perfoemance a lot as post back is not required for this operation..
|
|
|
|
 |
|
 |
Hi All ,
Expand/Collapse without post back is implemented .
Modifications to the exisitng code:
two files need to be modified.
1. TreeWeb.cs
2. TreeElementWriter.cs
1. Changes to TreeWeb.cs :
1.1 New method RenderSupportingJS helps us to render contents in differnt way where in it renders ExpandCollapseNode javascript, which sets div tags visibility.
private void RenderSupportingJS(HtmlTextWriter writer)
{
writer.WriteLine(@"<script language=JavaScript>
function ExpandCollapseNode(nodeId, imageId)
{
var div;
var img;
div=document.getElementById(nodeId);
img=document.getElementById(imageId);
if (div.style.display == 'none')
{
div.style.display = '';
img.src='" + this.ExpandedElementImage + @"';
}
else
{
div.style.display = 'none';
img.src='" + this.CollapsedElementImage + @"';
}
}
</script>
");
}
1.2. Modify Rendering functionality :
Call RenderSupportingJS
protected override void Render( HtmlTextWriter writer )
{
RenderSupportingJS(writer);
TreeWriter.RenderTree( writer, this );
}
2.TreeElementWriter.cs
2.1 RenderContents Using Div tags :
protected void RenderContents( HtmlTextWriter writer )
{
TableRow _tr = new TableRow();
TableCell _td = new TableCell();
_tr.RenderBeginTag( writer );
// apply CssClass for current element
if( _element.TreeWeb.DefaultElementCssClass.Length > 0 )
_td.CssClass = _element.TreeWeb.DefaultElementCssClass;
if( _element.CssClass.Length > 0 )
_td.CssClass = _element.CssClass;
//_td.Style.Add( "display", "none" );
_td.Attributes.Add( "nowrap", "yes" );
_td.RenderBeginTag( writer );
// render a at the begining of each element
writer.Write( " " );
// render element indentation based on element level
string _indentation = "";
for( int index = 0; index < _element.Level; index++ )
_indentation += _indentationStep;
writer.Write( _indentation );
// render the expand/collapse link if the element has child elements
if( _element.HasElements )
{
HyperLink _link = new HyperLink();
Image _image = new Image();
_image.ID=_element.ID+ "img";
if( _element.IsExpanded )
{
_link.Text = _expcol[1];
if( _element.TreeWeb.ExpandedElementImage.Length > 0 )
_image.ImageUrl = _element.TreeWeb.ExpandedElementImage;
}
else
{
_link.Text = _expcol[0];
if( _element.TreeWeb.CollapsedElementImage.Length > 0 )
_image.ImageUrl = _element.TreeWeb.CollapsedElementImage;
}
//string scriptCode = "javascript:";
//scriptCode += _element.TreeWeb.Page.GetPostBackEventReference( _element.TreeWeb, _element.ID );
string scriptCode = string.Format("javascript:ExpandCollapseNode('{0}','{1}')",_element.ID,_image.ClientID);
_link.NavigateUrl = scriptCode;
if( _image.ImageUrl.Length > 0 )
{
_link.RenderBeginTag( writer );
_image.RenderControl( writer );
_link.RenderEndTag( writer );
}
else
_link.RenderControl( writer );
_image = null;
_link = null;
writer.Write( " " );
}
// render checkbox
if( _element.TreeWeb.CheckBoxes || _element.CheckBox )
{
CheckBox _checkbox = new CheckBox();
_checkbox.ID = _element.ID + TreeElement._separator + TreeElement._checkboxIDSufix;
_checkbox.RenderControl( writer );
_checkbox = null;
// write a non-breaking space before the element text
writer.Write( " " );
}
// render element's image if it has one
if( _element.ImageIndex > -1 )
{
ElementImage _elementImage = _element.TreeWeb.ImageList[_element.ImageIndex];
if( _elementImage != null )
{
Image _image = new Image();
_image.ImageUrl = _elementImage.ImageUrl;
_image.RenderControl( writer );
_image = null;
// write a non-breaking space before the element text
writer.Write( " " );
}
}
// render element text as a link if NavigateUrl is present or otherwise as normal text
if( _element.NavigateUrl.Length > 0 )
{
HyperLink _linkNavigateUrl = new HyperLink();
_linkNavigateUrl.Text = _element.Text;
_linkNavigateUrl.NavigateUrl = _element.NavigateUrl;
if( _element.TreeWeb.Target.Length > 0 )
_linkNavigateUrl.Target = _element.TreeWeb.Target;
if( _element.Target.Length > 0 )
_linkNavigateUrl.Target = _element.Target;
if( _element.ToolTip.Length > 0 )
_linkNavigateUrl.ToolTip = _element.ToolTip;
_linkNavigateUrl.RenderControl( writer );
_linkNavigateUrl = null;
}
else
{
Label _label = new Label();
_label.Text = _element.Text;
if( _element.ToolTip.Length > 0 )
_label.ToolTip = _element.ToolTip;
_label.RenderControl( writer );
_label = null;
}
_td.RenderEndTag( writer );
_tr.RenderEndTag( writer );
}
I thank Iulian Iuga .
Iulian Iuga : Please add your valuable comments
Thanks
Kusal
|
|
|
|
 |
|
 |
Hey Kusal,
It looks really cool . Performace has drastically improved .. I am lookong for it for the past 2 years. Good job !!!!!
|
|
|
|
 |
|
 |
a "TreeWebCtrl" named TreeView in ASPNET20 can be Dragged in the Design View, can be attached to various DataSources, Auto Formated in 15 manners, edited...
I'm missing an episode, or this one became obsolete ?!
|
|
|
|
 |
|
 |
I'm using the TreeWeb control in my application. I also tried to use the CssClass attribute for treeweb control. But it doesn't show as per the style in the style sheet. I also tried to use font-name, font-size properties but no use. Please respond if you have used the same. Also if updated version of the control is available, please share that.
Thanks in advance.
Shelly
|
|
|
|
 |
|
 |
HI
I am working with this tree control can any one let me know that how i can check wether the check box is checked or not , i have read that IsChecked property is not implemented but any one can tell is this possible is there any way with which i can do it with this control or there is any other free ASP.Net tree Control Available not the trial version .
Do good and have good.
|
|
|
|
 |
|
 |
I have just started to use the TreeWeb (truly nice control by the way) and would be interested in getting an updated version of the control, in which the the problem with the Checkbox would be fixed as well as, if possible, the IsChecked method implemented.
Thanks for your help.
|
|
|
|
 |
|
 |
How I can create a property AutoPostBack for TreeWeb ?
|
|
|
|
 |
|
 |
I love this control, but I absolutely need to know which of the items were checked on postback. I notice the article mentions that this is not implemented but in one of your earlier replies you had mentioned updating your website with the ischecked functionality implemented. I am unable to access http://www7.brinkster.com/iigua/. Can you please email me the updated code.
Thanks
VJ
|
|
|
|
 |
|
 |
i also need the update where the ischecked functionality works...
can you please email it to me? thanks!
nice control btw
|
|
|
|
 |
|
 |
Dear iulian,
First of all thanks for providing such a nice tree control.
I am using your tree in my asp.net project. The problem I am facing is when I use your control directly in .aspx page , it works fine.
But when I put it in .ascx (custom control) and use this control in my aspx page , its Expand and Collapse events are not working ,
Clicking the +,- sign makes no difference i.e it does not expand or collapse.
I need your help urgently.
Any help would be greately appreciated…
Thanks,
Nikhil A.Vaghela
|
|
|
|
 |
|
 |
Expand event never occurs ((
I created a handle for it, but event is not throwen when i click on element.
|
|
|
|
 |
|
 |
Hey,
Well done, there have been many TreeView controls for .net but yours is actually native...Gave me some ideas that I probably would have never thought of, thanks!
But one thing, you really need to work on your coding style, and also prefixing your internal class variables with an _ will make them non CLR compliant, just an FYI for you int the future!!
I recommend reading up on Microsoft's internal coding rules that they have implemented in house for their own .Net projects. I dont follow them strictly, I personally prefix my internal classes with the member prefix m_Stuff something like that, which is still CLR compliant and doesnt look extremely cryptic when its next to other operators, for example you have things like _blah = _temp ? _pop : 4
Also you should always write out your if statements when possible, especially for clarity, I know it makes everyone feel cool and all using the compact versions, but in reality it makes it much more difficult to read for other developers...
Just some FYI stuff, Great Job, Love your project man!!
"Your KungFu is not strong enough"
|
|
|
|
 |
|
 |
Hi,
I am using a panel control to add the webTree to on the fly. I am using the following code snippet:
---------------------------------------------
TreeWeb treeView = new TreeWeb();
treeView.ID = "webTree1";
TreeElement _treeElement = new TreeElement( "element1" );
treeView.Elements.Add( _treeElement );
int index = treeView.Elements.Add( "element4" );
treeView.Elements[index].Elements.Add( "element5" );
phTreeView.Controls.Add(treeView);
It all goes well until the page renders, then you get an error "Object reference not set to an instance of an object"
Source Error:
Line 62: return _id;
Line 63:
Line 64: _id = Parent.ID + _separator + _idPrefix + Parent.Elements.IndexOf( this );
Line 65: return _id;
Line 66: }
Source File: D:\Data\Projects\TreeWebControl\TreeElement.cs Line: 64
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
iiuga.Web.UI.TreeElement.get_ID() in D:\Data\Projects\TreeWebControl\TreeElement.cs:64
iiuga.Web.UI.TreeElement.get_ID() in D:\Data\Projects\TreeWebControl\TreeElement.cs:64
iiuga.Web.UI.TreeElementWriter.RenderContents(HtmlTextWriter writer) in D:\Data\Projects\TreeWebControl\TreeElementWriter.cs:106
iiuga.Web.UI.TreeElementWriter.Render(HtmlTextWriter writer) in D:\Data\Projects\TreeWebControl\TreeElementWriter.cs:47
iiuga.Web.UI.TreeElementWriter.RenderElement(HtmlTextWriter writer, TreeElement element) in D:\Data\Projects\TreeWebControl\TreeElementWriter.cs:35
iiuga.Web.UI.TreeElement.Render(HtmlTextWriter writer) in D:\Data\Projects\TreeWebControl\TreeElement.cs:580
iiuga.Web.UI.TreeWebWriter.RenderChildren(HtmlTextWriter writer) in D:\Data\Projects\TreeWebControl\TreeWebWriter.cs:67
iiuga.Web.UI.TreeWebWriter.RenderContents(HtmlTextWriter writer) in D:\Data\Projects\TreeWebControl\TreeWebWriter.cs:52
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
iiuga.Web.UI.TreeWebWriter.RenderTree(HtmlTextWriter writer, TreeWeb tree) in D:\Data\Projects\TreeWebControl\TreeWebWriter.cs:34
iiuga.Web.UI.TreeWeb.Render(HtmlTextWriter writer) in d:\data\projects\treewebcontrol\treeweb.cs:457
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +44
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +262
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Page.ProcessRequestMain() +1926
------------------------------------------------------------
Any thoughts?
Thanks
|
|
|
|
 |
|
 |
I'm getting the same problem. Has anyone been able to figure out a way to solve this problem and how to dynamically create a webtree?
Thanks
|
|
|
|
 |
|
 |
Hi Iullian
Great control that you provide us.
I'm looking for help from you.
Is this a way that you explain me how can I expand your code to finish the CssClassOver funcionality.
Thanks
|
|
|
|
 |
|
 |
Hi Samuel,
sorry it took a little bit longer before I answered to your message.
You can anytime send me an email on my address (iulian_iuga@yahoo.com) and I will do my best to support you regarding the TreeWeb.
Thanks,
Iulian
|
|
|
|
 |
|
 |
when I expand/collapse a node with children, the same node is rendered again to screen. For ex: Suppose there is a node (call is 1) with a child 1.1 Initially when the page loads, node 1 is not expanded so the screen looks like this: >1 Now I expand the node and the screen looks like this: >1 1.1 >1 Why is node 1 being rendered again to the screen? Now if I collapse node 1, the screen looks like: >1 >1 >1 Node 1 is rendered again. This re-rendering of node 1 continues on every expansion/collapse. I would like to metnion that this behaviour is observed only for a tree that is built at runtime. Thanks
|
|
|
|
 |
|
 |
hi,
thanks for your message. Unfortunately I couldn't reproduce the problem. Can you still reproduce it? Have you changed something in the source code?
Iulian
|
|
|
|
 |
|
 |
try the following test code in a separate .aspx file
...
using iiuga;
....
....
protected iiuga.Web.UI.TreeWeb _treeWeb;
protected iiuga.Web.UI.TreeElement _root;
private void Page_Load( object sender, System.EventArgs ev )
{
_root = new iiuga.Web.UI.TreeElement("Root");
iiuga.Web.UI.TreeElement e = new iiuga.Web.UI.TreeElement("1");
_root.Elements.Add(e);
e.Elements.Add("1.1");
e = e.Elements[0];
e.Elements.Add("1.1.1");
_treeWeb.Elements.Add(_root);
}
I would greatly appreciate your help!
|
|
|
|
 |
|
 |
hi,
you are right, this code will always generate a new node in the tree. It has nothing to do with the TreeWeb, it has to do with the way it is used. You may probably want to do that:
private void Page_Load( object sender, System.EventArgs ev )
{
if( !IsPostBack )
{
_root = new iiuga.Web.UI.TreeElement("Root");
iiuga.Web.UI.TreeElement e = new iiuga.Web.UI.TreeElement("1");
_root.Elements.Add(e);
e.Elements.Add("1.1");
e = e.Elements[0];
e.Elements.Add("1.1.1");
_treeWeb.Elements.Add(_root);
}
}
That means, you are loading/seting the tree structure first time when the page is loaded, and not every time when you submit the page.
That's the pattern how the controls in ASP.NET webforms are initialised.
Iulian
|
|
|
|
 |
|
 |
Hey Iulian,
thanks a lot. I realized my mistake. The tree needs to be built only the 1st time the page loads. Not on every postback! The event handler will take care of expanding/collapsing the node that triggered the postback.
Thhanks
|
|
|
|
 |