Search Results

Search found 5 results on 1 pages for 'treecontrol'.

Page 1/1 | 1 

  • jQuery Treeview – Expand and Collapse All Without the TreeControl

    - by Ben Griswold
    The jQuery Treeview Plugin provides collapse all, expand all and toggle all support with very little effort on your part. Simply add a treecontrol with three links, and the treeview, to your page…   <div id="treecontrol">     <a title="Collapse the entire tree below" href="#"><img src="../images/minus.gif" /> Collapse All</a>     <a title="Expand the entire tree below" href="#"><img src="../images/plus.gif" /> Expand All</a>     <a title="Toggle the tree below, opening closed branches, closing open branches" href="#">Toggle All</a> </div> <ul id="treeview" class="treeview-black">     <li>Item 1</li>     <li>         <span>Item 2</span>         <ul>             <li>                 <span>Item 2.1</span>                   <ul>                     <li>Item 2.1.1</li>                     <li>Item 2.1.2</li>                 </ul>             </li>             <li>Item 2.2</li>             <li class="closed">                   <span>Item 2.3 (closed at start)</span>                 <ul>                     <li>Item 2.3.1</li>                     <li>Item 2.3.2</li>                 </ul>             </li>         </ul>     </li> </ul> …and then associate the control to the treeview when defining the treeview settings. $("#treeview").treeview({     control: "#treecontrol",     persist: "cookie",     cookieId: "treeview-black" }); It really couldn’t be easier and it works great! But the plugin doesn’t offer a lot of flexibility when it comes to layout.  For example, the plugin assumes your treecontrol will include links.  If you want buttons or images or whatever, you are out of luck.  The plugin also assumes a set number of links and the collapse all handler is associated with the first link inside of the treecontrol, a:eq(0), the expand all handler is associated with the second link and so on.  So you really can’t incorporate the toggle all link by itself unless you manually hide the other options. Which brings me to the point of this post – making the collapse/expand/toggle layout more flexible without modifying the plugin’s source code. We will continue to use the treecontrol actions but we’re not going to use them directly. In fact, our custom collapse, expand and toggle links will trigger the actions for us.  So, hide the treecontrol links and associate the treecontrol click events with the click events of other controls.  Finally, render the treeview with the same setting definitions as usual. $(document).ready(function() {     // The plugin shows the treecontrol after the     // collapse, expand and toggle events are hooked up     // Just hide the links.     $('#treecontrol a').hide();       // On click of your custom links, button, etc     // Trigger the appropriate treecontrol click     $('#expandAll').click(function() {                 $('#treecontrol a:eq(1)').click();         });          $('#collapseAll').click(function() {         $('#treecontrol a:eq(0)').click();             });       // Render the treeview per usual.         $("#treeview").treeview({         control: "#treecontrol",         persist: "cookie",         cookieId: "treeview-black"     }); }); Since I’m not using the treecontrol directly, I move it to the bottom of the page but it doesn’t really matter where the treecontrol goes. <div>     <a id="collapseAll" href="#">Collapse All Outside of TreeControl</a> </div>   <ul id="treeview" class="treeview-black">     <li>Item 1</li>     <li>         <span>Item 2</span>         <ul>             <li>                 <span>Item 2.1</span>                 <ul>                     <li>Item 2.1.1</li>                     <li>Item 2.1.2</li>                 </ul>             </li>             <li>Item 2.2</li>             <li class="closed">                 <span>Item 2.3 (closed at start)</span>                 <ul>                     <li>Item 2.3.1</li>                     <li>Item 2.3.2</li>                 </ul>             </li>         </ul>     </li> </ul>   <div>     <input type="button" id="expandAll" value="Expand All Outside of TreeControl"/> </div>   <div id="treecontrol">     <a href="#"></a><a href="#"></a><a href="#"></a> </div> The above jQuery and Html snippets generate the following ugly output which shows the separated collapse/expand elements. If you want the toggle all option, I bet you can figure out how to put it in place.  I’ve made the source available below if you’re interested. Download jQuery Treeview Expand and Collapse Super Code

    Read the article

  • MFC CTreeCtrl max visible item text length

    - by Steven smethurst
    Hello I have an application that outputs large amounts of text data to an MFC tree control. When I call SetItemText() with a long string (larger then 1000+ char) only the first ~250 chars are displayed in the control. But when I call GetItemText() on the item the entire string is returned (1000+ chars) My questions are; Is there a MAX visible string length for a MFC tree control? Is there any way to increase the visible limit? I have included example text code below // In header CTreeCtrl m_Tree; // In .cpp file void CTestDlg::OnDiagnosticsDebug() { CString csText; CString csItemText; csText.Format( _T("0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789") ); for( int i = 0 ; i < 10 ; i ++ ) { csItemText += csText ; } bool b = m_Tree.SetItemText( m_Tree.GetRootItem(), csItemText ); return ; }

    Read the article

  • How Do I Create Expand All and Collapse All Links Outside of the jQuery Treeview Plugin?

    - by Ben Griswold
    The jQuery Treeview Plugin adds Collapse All, Expand All and Toggle All links to the "treeviewcontrol" div when the control property is defined as follows: $("#black, #gray").treeview({ control: "#treecontrol", persist: "cookie", cookieId: "treeview-black" }); This works great, but I'd like the ability to expand and collapse the treeview from other page elements outside of the treeview itself. I've looked at the source, but I can't figure it out.

    Read the article

  • VB.Net Custom Controls

    - by Paul
    This might be basic question, however I am confused on some .Net Concpets. I am trying to create a "Data Browser" in VB.net. Similar to a Web Browser however each Tab in the Data Browser is a view of some Data (from a database or flat files) not a webpage. The UI on each Tab is mostly the same. A list Box (showing datatypes, etc), a TextBox (where you can create a filter), and a DataGridView, a DataSource Picker, etc. The only thing that would change on each tab is that there could be a custom "Viewer". In most cases (depending on the datasource), this would be the datagrid, however in other cases it would be a treecontrol. From reading through the .Net documents, it appears that I need to Create a Custom Control (MyDataBrowser) Consisting of a Panel with all the common Controls (except the viewer). Every time the user says "New Tab", a new tabpage is created and this MyDataBrowser Control is added, The MyDataBrowser control would contain some function that was able to then create the approriate viewer based on the data at hand. If this is the suggested route, how is the best way to go about creating the MyDataBrowser Control (A) Is this a Custom Control Library? (B) Is this an Inhertited Form? (C) Is this an Inherrited User Control? I assume that I have to create a .DLL and add as a reference. Any direction on this would be appreciated. Does the custom Control have its own properties (I would like to save/load these from a configuration file). Is it possible to add a backgroundworker to this customcontrol? Thanks.

    Read the article

  • How to implement Cocoa copyWithZone on derived object in MonoMac C#?

    - by Justin Aquadro
    I'm currently porting a small Winforms-based .NET application to use a native Mac front-end with MonoMac. The application has a TreeControl with icons and text, which does not exist out of the box in Cocoa. So far, I've ported almost all of the ImageAndTextCell code in Apple's DragNDrop example: https://developer.apple.com/library/mac/#samplecode/DragNDropOutlineView/Listings/ImageAndTextCell_m.html#//apple_ref/doc/uid/DTS40008831-ImageAndTextCell_m-DontLinkElementID_6, which is assigned to an NSOutlineView as a custom cell. It seems to be working almost perfectly, except that I have not figured out how to properly port the copyWithZone method. Unfortunately, this means the internal copies that NSOutlineView is making do not have the image field, and it leads to the images briefly vanishing during expand and collapse operations. The objective-c code in question is: - (id)copyWithZone:(NSZone *)zone { ImageAndTextCell *cell = (ImageAndTextCell *)[super copyWithZone:zone]; // The image ivar will be directly copied; we need to retain or copy it. cell->image = [image retain]; return cell; } The first line is what's tripping me up, as MonoMac does not expose a copyWithZone method, and I don't know how to otherwise call it. Update Based on current answers and additional research and testing, I've come up with a variety of models for copying an object. static List<ImageAndTextCell> _refPool = new List<ImageAndTextCell>(); // Method 1 static IntPtr selRetain = Selector.GetHandle ("retain"); [Export("copyWithZone:")] public virtual NSObject CopyWithZone(IntPtr zone) { ImageAndTextCell cell = new ImageAndTextCell() { Title = Title, Image = Image, }; Messaging.void_objc_msgSend (cell.Handle, selRetain); return cell; } // Method 2 [Export("copyWithZone:")] public virtual NSObject CopyWithZone(IntPtr zone) { ImageAndTextCell cell = new ImageAndTextCell() { Title = Title, Image = Image, }; _refPool.Add(cell); return cell; } [Export("dealloc")] public void Dealloc () { _refPool.Remove(this); this.Dispose(); } // Method 3 static IntPtr selRetain = Selector.GetHandle ("retain"); [Export("copyWithZone:")] public virtual NSObject CopyWithZone(IntPtr zone) { ImageAndTextCell cell = new ImageAndTextCell() { Title = Title, Image = Image, }; _refPool.Add(cell); Messaging.void_objc_msgSend (cell.Handle, selRetain); return cell; } // Method 4 static IntPtr selRetain = Selector.GetHandle ("retain"); static IntPtr selRetainCount = Selector.GetHandle("retainCount"); [Export("copyWithZone:")] public virtual NSObject CopyWithZone (IntPtr zone) { ImageAndTextCell cell = new ImageAndTextCell () { Title = Title, Image = Image, }; _refPool.Add (cell); Messaging.void_objc_msgSend (cell.Handle, selRetain); return cell; } public void PeriodicCleanup () { List<ImageAndTextCell> markedForDelete = new List<ImageAndTextCell> (); foreach (ImageAndTextCell cell in _refPool) { uint count = Messaging.UInt32_objc_msgSend (cell.Handle, selRetainCount); if (count == 1) markedForDelete.Add (cell); } foreach (ImageAndTextCell cell in markedForDelete) { _refPool.Remove (cell); cell.Dispose (); } } // Method 5 static IntPtr selCopyWithZone = Selector.GetHandle("copyWithZone:"); [Export("copyWithZone:")] public virtual NSObject CopyWithZone(IntPtr zone) { IntPtr copyHandle = Messaging.IntPtr_objc_msgSendSuper_IntPtr(SuperHandle, selCopyWithZone, zone); ImageAndTextCell cell = new ImageAndTextCell(copyHandle) { Image = Image, }; _refPool.Add(cell); return cell; } Method 1: Increases the retain count of the unmanaged object. The unmanaged object will persist persist forever (I think? dealloc never called), and the managed object will be harvested early. Seems to be lose-lose all-around, but runs in practice. Method 2: Saves a reference of the managed object. The unmanaged object is left alone, and dealloc appears to be invoked at a reasonable time by the caller. At this point the managed object is released and disposed. This seems reasonable, but on the downside the base type's dealloc won't be run (I think?) Method 3: Increases the retain count and saves a reference. Unmanaged and managed objects leak forever. Method 4: Extends Method 3 by adding a cleanup function that is run periodically (e.g. during Init of each new ImageAndTextCell object). The cleanup function checks the retain counts of the stored objects. A retain count of 1 means the caller has released it, so we should as well. Should eliminate leaking in theory. Method 5: Attempt to invoke the copyWithZone method on the base type, and then construct a new ImageAndTextView object with the resulting handle. Seems to do the right thing (the base data is cloned). Internally, NSObject bumps the retain count on objects constructed like this, so we also use the PeriodicCleanup function to release these objects when they're no longer used. Based on the above, I believe Method 5 is the best approach since it should be the only one that results in a truly correct copy of the base type data, but I don't know if the approach is inherently dangerous (I am also making some assumptions about the underlying implementation of NSObject). So far nothing bad has happened "yet", but if anyone is able to vet my analysis then I would be more confident going forward.

    Read the article

1