简体   繁体   English

在Meteor中级联选择控件

[英]Cascading select controls in Meteor

I'm using Meteor 1.* and would like to create two cascading "dependent" select controls on a form. 我正在使用Meteor 1. *,并想在窗体上创建两个级联的“依赖”选择控件。

For example, a Countries/Cities or or "Car Maker"/"Car Model" -- basically a parent child relationship. 例如,一个国家/城市或“汽车制造商” /“汽车模型”-基本上是父子关系。

I don't want to retrieve the data from the database each time I select the parent category. 我不想每次选择父类别时都从数据库中检索数据。

I'd like to have something along these lines: 我想遵循以下思路:

Template.registerHelper("getCarMakers", function () {
  return [
    {label: "Chevy", value: "camaro"},
    {label: "Chevy", value: "corvette"},
    {label: "Ford", value: "mustang"},
    {label: "Dodge", value: "viper"},
    {label: "Dodge", value: "charger"}
  ];
});

The above is what I'd normally do to populate a regular select control. 以上是我通常为填充常规选择控件所做的事情。

But the list will be too big in my case. 但是对于我来说,这个列表太大了。 And further, the reason I just don't make a group select control is again, because this list is just too big. 再者,我之所以没有进行组选择控件,是因为该列表太大了。 Also, the reason I don't make a group select with a search option, is because I don't want introduce that feature at this time (maybe in the future I'd do something like this to account for large lists). 另外,我之所以没有使用搜索选项进行组选择的原因是因为我现在不想引入该功能(也许将来我会做类似的事情来说明大列表)。

So I'd like to make two select controls. 所以我想做两个选择控件。 The first will have the high level category (or parent), and based on that selection, the second select control would "display" or "filter" the related items or "child" items. 第一个将具有高级类别(或父类别),并且基于该选择,第二个选择控件将“显示”或“过滤”相关项目或“子”项目。

I don't mind pushing all the data to the client to start and then filtering (actually I'd prefer doing that). 我不介意将所有数据推送到客户端开始然后进行过滤(实际上我更喜欢这样做)。

For meteor packages that might help, take a look at: 对于可能有用的流星包,请查看:

Depending on your data set size, you might run into localstorage limitations, so you might need to check your target browser capacities. 根据数据集的大小,您可能会遇到本地存储限制,因此可能需要检查目标浏览器容量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM