tag:blogger.com,1999:blog-15136575.post2346269083041919375..comments2023-10-17T12:00:16.772+01:00Comments on Code rant: Rendering a tree view using the MVC FrameworkMike Hadlowhttp://www.blogger.com/profile/16441901713967254504noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-15136575.post-92008795980034014462015-02-24T12:05:06.016+00:002015-02-24T12:05:06.016+00:00Beside of that, HashedSet needs to be replaced by ...Beside of that, HashedSet needs to be replaced by HashSet, unless you use an own implementation of HashedSet.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-15136575.post-63445591279438843272015-02-24T12:01:48.559+00:002015-02-24T12:01:48.559+00:00Hi, I'm also unable to get this example work.....Hi, I'm also unable to get this example work...<br /><br />The viewModel says that it is from type CompositeThing, see "Html.RenderTree((CompositeThing)ViewData.Model, thing => thing.Name)".<br /><br />The HtmlHelper Extension RenderTree awaits IEnumerable rootLocations as parameter.<br /><br />The compiler tells (correctly) that (CompositeThing)ViewData.Model cannot be used since IEnumerable is awaited as type for the first parameter in "Html.RenderTree((CompositeThing)ViewData.Model, thing => thing.Name)". <br /><br />Or did I overlook something?<br />Many thanks!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-15136575.post-80601498619900006072013-04-17T14:37:23.144+01:002013-04-17T14:37:23.144+01:00Please add a download source.
I'm unable to ge...Please add a download source.<br />I'm unable to get the jquery treeview to work.Shimmyhttps://www.blogger.com/profile/16979929680149204626noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-76447683595567591432013-01-02T05:08:42.538+00:002013-01-02T05:08:42.538+00:00Great walkthrough.
Easy to understand and I took t...Great walkthrough.<br />Easy to understand and I took the opportunity to use it to render the tree structure of blog posts on my website and described this little "case study"<br /><br /><a href="http://www.ynegve.info/Post/156/implementing-a-tree-view-small-case-study" rel="nofollow">Implementing a Tree View - Small Case Study</a><br /><br /><a href="https://plus.google.com/112677661119561622427?rel=author" title="Evgeny" rel="nofollow">Evgeny</a>Anonymoushttps://www.blogger.com/profile/11830223012436462556noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-78859216554390542532012-05-04T20:38:39.008+01:002012-05-04T20:38:39.008+01:00Thanks MikeThanks Mikesuraj.nairhttps://www.blogger.com/profile/16008980823025417478noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-23766472870417412252012-04-27T14:27:51.736+01:002012-04-27T14:27:51.736+01:00Hi Mike,
I have a requirement which is to display ...Hi Mike,<br />I have a requirement which is to display data on a treeview(Parent-Child format).<br />When any of the child node is clicked,its id should be passed to the controller and its corresponding data should be brought and displayed on the right hand side panel of the Html Form.<br />Help would be highly appreciated..<br />Thanks in Advance..Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-15136575.post-73034333870453154942011-11-10T00:27:06.950+00:002011-11-10T00:27:06.950+00:00@Ryan - you need to add the following to your web ...@Ryan - you need to add the following to your web config...<br /> <br /> <br /> <br /> <br /> <br /> <br />....Tricky Dickyhttps://www.blogger.com/profile/16559315295872522385noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-40229898868735681752011-10-17T07:46:38.440+01:002011-10-17T07:46:38.440+01:00Hi Mike,
Thank you very much for your posting, I...Hi Mike, <br /><br />Thank you very much for your posting, I do it the same with your way, but I get this error, what's wrong with me? Please help!<br /><br /> 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'TreeRender' and no extension method 'TreeRender' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)Ryanhttps://www.blogger.com/profile/11332525356493654592noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-18204576146841569602011-10-04T15:03:26.801+01:002011-10-04T15:03:26.801+01:00thanxxxxxxx A lot MiKethanxxxxxxx A lot<b> MiKe </b>KHANhttps://www.blogger.com/profile/03195103224223651944noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-21255190292828519322011-07-27T13:12:47.792+01:002011-07-27T13:12:47.792+01:00hi mike,
excellent post!
I just want to know where...hi mike,<br />excellent post!<br />I just want to know where to place the methods you described since i'm relatively new to MVC. I tried placing the code in the controller or custom models, but I am getting error<br />1)extension method must be defined in non-generic static class<br />2)The type or namespace name 'TreeRenderer' could not be found (are you missing a using directive or an assembly reference?)<br />3)Warning as Error: Type parameter 'T' has the same name as the type parameter from outer typeabhishek madhekarhttps://www.blogger.com/profile/08049409399891849479noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-46362994422099085192010-11-27T01:23:23.809+00:002010-11-27T01:23:23.809+00:00Nice and clean.
Works like a charm.
Thank youNice and clean.<br />Works like a charm.<br /><br />Thank youTomislavnoreply@blogger.comtag:blogger.com,1999:blog-15136575.post-71728609897110669542010-06-06T15:34:33.938+01:002010-06-06T15:34:33.938+01:00<%= Html.RenderTree((CompositeThing)ViewData.Mo...<%= Html.RenderTree((CompositeThing)ViewData.Model,thing => thing.Name)%><br /><br />gives me server error. The system says,<br />Compiler Error Message: CS1928: 'System.Web.Mvc.HtmlHelper>' does not contain a definition for 'RenderTree' and the best extension method overload 'Controls.TreeRenderHtmlHelper.RenderTree(System.Web.Mvc.HtmlHelper, System.Collections.Generic.IEnumerable, System.Func)' has some invalid arguments<br /><br /><br />help appreciatedVinojhttps://www.blogger.com/profile/15075219261819404044noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-31183658851541253612009-12-13T23:02:26.947+00:002009-12-13T23:02:26.947+00:00Hi Mike, I believe came late to your post activity...Hi Mike, I believe came late to your post activity but reviewing I found it very interesting, just have a question, do you have any sample where you implement this post but all-in-one, using the 3 concerns: Model, View, Controller. <br /><br />This help a lot to understand how do you fill a List of CompositeThing elements in recursive mode.<br /><br />Thanks in advance. <br />RC.Roberto Cervanteshttps://www.blogger.com/profile/13797162440234353256noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-67854398225240286822009-12-10T12:55:58.434+00:002009-12-10T12:55:58.434+00:00I am not passing any value for Html Helper in Htm...I am not passing any value for Html Helper in HtmlHelper.RenderTree<br /><br />If I wont pass a value it gives me error saying argument not specified.<br /><br />So I have removed the parameter in RenderTree<br /><br />will it be a problem.<br /><br />Could you please tell me what to pass their..<br /><br />ThanksAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-15136575.post-91043757394713492802009-12-10T12:51:30.221+00:002009-12-10T12:51:30.221+00:00Hi Mike,
I am getting following error in my
HtmlH...Hi Mike,<br />I am getting following error in my <br />HtmlHelper.RenderTree<br /><br />Argument type CompositeThing is not assignable to parameter type System.Collections.Generics.IEnumerable of CompositThing<br /><br />Could you please tell me what is the problem.<br /><br />ThanksAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-15136575.post-86197265353773762192009-08-02T19:03:09.776+01:002009-08-02T19:03:09.776+01:00Hi Mike,
Thanks a lot.
It working fine now.
Than...Hi Mike,<br /><br />Thanks a lot.<br />It working fine now.<br /><br />Thanks & Regards,<br />Kiran KirdatUnknownhttps://www.blogger.com/profile/01792357740865493760noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-57181107511091003572009-07-28T21:32:11.185+01:002009-07-28T21:32:11.185+01:00Kiran,
Try changing this line:
Html.RenderTree((C...Kiran,<br /><br />Try changing this line:<br />Html.RenderTree((CompositeThing)ViewData.Model, thing => thing.Name) <br /><br />to this:<br />Html.RenderTree<CompositeThing>((CompositeThing)ViewData.Model, thing => thing.Name)Mike Hadlowhttps://www.blogger.com/profile/16441901713967254504noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-69676489807392954782009-07-28T16:10:01.976+01:002009-07-28T16:10:01.976+01:00Thanks a Lot Mike !..
The program is compiling now...Thanks a Lot Mike !..<br />The program is compiling now. But again Iam having following issues.<br />=========Beging HTML Content============<br /> Html.RenderTree((CompositeThing)ViewData.Model, thing => thing.Name) <br />=========End HTML Content============<br /><br />========Begin Model=======<br /><br />public class CompositeThing : IComposite<CompositeThing><br /> {<br /> public CompositeThing()<br /> {<br /> Children = new List<CompositeThing>();<br /> }<br /> public string Name { get; set; }<br /> public CompositeThing Parent { get; set; }<br /> public IEnumerable<CompositeThing> Children { get; set; }<br /> }<br /><br /> public interface IComposite<T><br /> {<br /> T Parent { get; }<br /> IEnumerable<T> Children { get; }<br /> }<br /> <br />======End Model===============<br /><br />====Index method===============<br />public ActionResult Index()<br /> {<br /> ViewData["Message"] = "Welcome to ASP.NET MVC!";<br /><br /> CompositeThing com = new CompositeThing();<br /> List<CompositeThing> test = new List<CompositeThing>();<br /><br /> CompositeThing child1 = new CompositeThing();<br /> child1.Name = "C1";<br /><br /> CompositeThing child2 = new CompositeThing();<br /> child2.Name = "C2";<br /> test.Add(child1);<br /> test.Add(child2);<br /><br /> com.Children = test;<br /><br /> CompositeThing Parent = new CompositeThing();<br /> Parent.Name = "Main";<br /> com.Parent = Parent;<br /><br /> return View(com);<br /> }<br />=================================<br /><br /><br />I am trying to use the aboce code but below is the error I am getting.<br />"The type arguments for method 'TestAppTree.Helper.TreeRenderHtmlHelper.RenderTree<T>(System.Web.Mvc.HtmlHelper, System.Collections.Generic.IEnumerable<T>, System.Func<T,string>)' cannot be inferred from the usage. Try specifying the type arguments explicitly."<br /><br />It will be of great help If you let me know the reason for this error<br /><br />Thanks & Regards,<br />KKUnknownhttps://www.blogger.com/profile/01792357740865493760noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-16088270171614612302009-07-27T21:57:51.542+01:002009-07-27T21:57:51.542+01:00Hi Kiran. That ForEach is a little extension metho...Hi Kiran. That ForEach is a little extension method. There are loads of examples around. See my post here for one (called Each in this case):<br /><br />http://mikehadlow.blogspot.com/2008/02/never-write-for-loop-again-fun-with.htmlMike Hadlowhttps://www.blogger.com/profile/16441901713967254504noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-82719520604156038912009-07-27T21:51:52.073+01:002009-07-27T21:51:52.073+01:00Hi Mike,
I tried using IEnumerable T instead of I...Hi Mike,<br /><br />I tried using IEnumerable T instead of Iset. I am getting below error:<br />'System.Collections.Generic.IEnumerable T ' does not contain a definition for 'Foreach' and no extension method 'Foreach' accepting a first argument of type 'System.Collections.Generic.IEnumerable T ' could be found (are you missing a using directive or an assembly reference?) <br /><br />The code which is giving above error is:<br />InUl(() => locations.Foreach(location => <br /> {<br /> writer.Write(locationRenderer(location));<br /> RenderLocations(location.Children);<br /> }));<br />Can you please let me know if I am missing anything here<br /><br />Thanks in advance.<br /><br />Regards,<br />KKUnknownhttps://www.blogger.com/profile/01792357740865493760noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-90554543420898708272009-06-16T07:32:55.908+01:002009-06-16T07:32:55.908+01:00Difficult to make it live because of source codes ...Difficult to make it live because of source codes is not released<br /><br />Having fun now trying to make it work with my data setAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-15136575.post-89797984805301362482008-11-02T08:35:00.000+00:002008-11-02T08:35:00.000+00:00This comment has been removed by a blog administrator.Saiful Alamhttps://www.blogger.com/profile/16938645337644875643noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-9787644771345003052008-10-24T09:24:00.000+01:002008-10-24T09:24:00.000+01:00I had a question today about ISet<T>. The ap...I had a question today about ISet<T>. The application I'm currently working on is using NHibernate. One of NHibernates foibles is that it likes you to define your collections using the Iesi.Collections library. ISet<T> is the interface for a set in that library. You could simply replace ISet<T> with IEnumerable<T> and HashedSet<T> with List<T> and everything should still work.Mike Hadlowhttps://www.blogger.com/profile/16441901713967254504noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-80595080583770562862008-10-22T13:55:00.000+01:002008-10-22T13:55:00.000+01:00Thanks Ed, you're welcome!Thanks Ed, you're welcome!Mike Hadlowhttps://www.blogger.com/profile/16441901713967254504noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-26814963822655302432008-10-22T13:22:00.000+01:002008-10-22T13:22:00.000+01:00That's bloody useful Mike. Thank you.That's bloody useful Mike. Thank you.Unknownhttps://www.blogger.com/profile/17319155837952777481noreply@blogger.com