2016-08-23 55 views
0

我不确定我们是否已经使用单个数据源在打开菜单中显示分页器。我尝试了多种组合,试图寻找解决方案,但无法获得任何解决方案。键入菜单中的分隔符?

更多类似下面的屏幕截图,我已经从单个源此数据为:

['US: channel1', 'US: channel2', 'US: channel3', 'US: channel4', 'US: channel5', 'CA: channel1', 'CA: channel2'] 

在上面的数据,我想后美国显示一个分离器基于信道,然后示出了CA信道的选择。

enter image description here

我可以更新数据源如果需要的话用于示出分离器到多dimenational阵列或任何其他定制。或者,在typeaheadjs范围之外的任何其他方式。

请帮我找一个工作解决方案。

回答

1

我想我会回答我的问题。这是如何做到的。

我插入了一个空白值,将被替换为分隔符。

['US: channel1', 'US: channel2', 'US: channel3', 'US: channel4', 'US: channel5', '', 'CA: channel1', 'CA: channel2'] 

要插入空白数据,我们可能必须使用单数据源的多维数组。

,并使用typeahead:render事件typeaheadjs的,我不得不处理,如下图所示:

$(input).bind('typeahead:render', function (e) { 
    var currentInput = $(e.target), 
     options; 

    options = $(currentInput).closest('.column-filter').find('.tt-suggestion'); 
    $(options).each(function (index, element) { 
     if (!$(element).text().trim().length) { 
      $(element).replaceWith('<hr>'); 
     } 
    }); 
}); 

jsfiddle link与工作的例子。