使用ASP.NET,jQuery和口鱼一个数据库驱动的菜单 [英] Building a database driven menu with ASP.NET, JQuery and Suckerfish

查看:96
本文介绍了使用ASP.NET,jQuery和口鱼一个数据库驱动的菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在使用口鱼的CSS菜单和jQuery从表中创建一个菜单。我用这个作为我的参考:口鱼菜单与ASP.NET和JQuery 而且我已经与手动提供链接(很像文章)的工作。

I'm attempting at creating a menu from a table using the Suckerfish css menu and Jquery. I'm using this as my reference: Suckerfish menu with ASP.NET and JQuery and I have it working with manually supplied links (much like in the article).

如果我有问题,正在写递归函数从数据库中获取的菜单项,并创建在适当的层次结构中的新菜单项。我的数据库表看起来像这样:

Where I'm having issues is writing the recursive function to get the menu items from the database and create the new menu items in the proper hierarchy. My database table looks like so:

表菜单


Table Menu


MENUID
PARENTID
链接
文本

MenuID ParentID Link Text

这个想法是,如果一个项目是一个父级项目MENUID和PARENTID是相同的,如果它是一个孩子,将有MENUID的它在PARENTID外地的父母。我需要创建一个可以顺利通过并找到所有孩子的家长一个函数(可能是几级),并把它替换这样的手册条目:

The idea being that if an item is a parent-level item the MenuID and ParentID are the same, if it's a child it will have the MenuID of it's parent in the ParentID field. I'm needing to create a function that can go through and find all of the children for the parents (could be a few levels) and have it replace manual entries like this:

        Dim Foo As New MenuItem("#", "Foo", Me)
        Items.Add(Foo)
        Foo.Items.Add(New MenuItem("#", "1", Me))
        Foo.Items.Add(New MenuItem("#", "2", Me))
        Foo.Items.Add(New MenuItem("#", "3", Me))
        Foo.Items.Add(New MenuItem("#", "4", Me))

我愿意更改数据库表结构如果有必要,基本上做别的得到这个打算。

I'm open to changing the database table structure if necessary and basically doing anything else to get this going.

感谢您的任何投入,它更AP preciated。

Thanks for any input, it's much appreciated.

推荐答案

再presenting分层数据的方法是很容易理解的人类,但很难从数据中提取的,因为它需要递归来提取完整​​的层次。 SQL的一些味道有会为你做这个命令,但是这是怎么回事幕后。

That method of representing hierarchical data is easy to understand for humans but difficult to extract data from, because it requires recursion to extract the full hierarchy. Some flavors of SQL have commands that will do this for you, but that is what is going on behind the scenes.

我建议你阅读更多的树木和放大器;层次结构在SQL ,并用它解释了物化路径法调整你的架构。这是很容易对查询和尺度真的很好。

I suggest you read More Trees & Hierarchies in SQL, and restructure your schema using the materialized path method that it explains. It is easy to query against and scales really well.

这篇关于使用ASP.NET,jQuery和口鱼一个数据库驱动的菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆