自动填充使用jQuery和功率选择框; AJAX在asp.net MVC功率、AJAX、jQuery、MVC

2023-09-10 17:03:25 作者:坟前蹦迪

1-问题:我需要,使用户能够从大量的信息被分组为一个分级结构进行选择,数据输入中选择一个或更多的东西,是数据可具有4,5父类别的深度。

1-problem: I need to enable users to select one or more things from a large amount of information that is grouped into a hierarchical structure for selection, data entry, were data could have a depth of 4, 5 parent categories.

2,功能I'm寻找: 类似eBay的显示选择项目的类别时,级联列表。当显示的页面,你只能得到第一个列表框中。在第一选择一个后,显示在第二。该过程继续进行,直到所选择的类别不具有子类

2-functionality I´m looking for: Similar to eBay shows cascading lists when selecting an item’s category. When the page is displayed, you only get the first list box. After selecting one in the first, the second is displayed. The process continues until the selected category does not have sub-categories.

}

}

3,实际的表和查询: 表:

3-actual table and query: table:

- 诠释编号

-string名称

- 诠释的ParentId

-int ParentId

查询:

public IList<CategoryTable> listcategories(int parentId)

            {
            var query = from c in categorytable
                        where c.ParentId == parentId
                        select c;

                var result= query.ToList();
                return result;
}

4 - 我不知道如何下手,任何指引,活生生的例子的jsfiddle,演示或教程将大大AP preciated。 brgds

4-I dont know how to start, any guideline, live example jsfiddle, demo or tutorial would be greatly appreciated. brgds

更新:我认为这个功能不是很在webtutorials和问题的发展。所以我开始赏金为一个伟大的答案。我会ASIGN的赏金的功能previous一个活生生的例子评论。谢谢!

UPDATE: I believe that this functionality is not very developed in webtutorials and questions. consequently I started a bounty for a great answer. I will asign the bounty for a live example of the functionality previous commented. thanks!

推荐答案

我使用的是敲除和的WebAPI电源级联下拉菜单中的应用程序我开发的时刻。

I'm using knockout and Webapi to power cascading dropdowns in an app I'm developing at the moment.

查看 我有一个基本的下拉列表如下图所示。

View I've got a basic dropdown list like below.

<select data-bind="options: CurrentList, 
                   optionsText: 'name',                                                        
                   value: CurrentListSelectedItem,
                   optionsCaption: 'Please Select...'"></select>

视图模型

self.CurrentList = ko.observableArray(CurrentListData);
self.CurrentListSelectedItem = ko.observable();
self.CurrentListSelectedItem.subscribe(function () {
    //ajaxcall to populate list 2
});

服务器端我有一个简单的REST服务,走在树中的一个点的ID,并返回其所有的孩子,这样一来,你想你可以链为许多这样的下拉菜单一起(只要你的等级有水平相匹配。

Server side I've got a simple rest service that take an Id of a point in the tree and returns all its children, this way you can just chain as many of these dropdowns together as you wish (as long as your hierarchy has the levels to match.

请参阅工作示例的拨弄着嘲笑的数据 http://jsfiddle.net/tgriley1/vEBGS/

See fiddle of working example with mocked data http://jsfiddle.net/tgriley1/vEBGS/

 
精彩推荐
图片推荐