Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group by categories #11

Closed
keithslater opened this issue Feb 20, 2013 · 8 comments
Closed

Group by categories #11

keithslater opened this issue Feb 20, 2013 · 8 comments
Milestone

Comments

@keithslater
Copy link

Anyway to group results by categories? It would be nice to show the category name and list the items below it.

@timtrueman
Copy link
Contributor

The results are grouped by dataset. Maybe we need two templates: one for each result and one for each dataset (category) of results

@vskarich
Copy link
Collaborator

Custom grouping would be nice to add, would have to support an optional category attribute in the datum object.

@jharding
Copy link
Contributor

The datasets would be the categories.

@jharding
Copy link
Contributor

The changes I made in #15 make something like this pretty easy. We could add header and footer to the dataset options and generate something like this:

<div class="tt-dropdown-menu">
  {{#dataset}}
    <div class="tt-dataset-{{name}}">
      <!-- HEADER GOES HERE -->
      <div class="tt-suggestions">
        {{#suggestions}}
          <div class="tt-suggestion">{{{html}}}<div>
        {{/suggestions}}
      </div>
      <!-- FOOTER GOES HERE -->
  {{/dataset}}
</div>

I don't really see any downside to this and I could have it ready to go for v0.9. @keithslater would this solve your issue?

@daraosn
Copy link
Contributor

daraosn commented Feb 22, 2013

What if the multiple datasets point to the same remote url (as twitter does with https://twitter.com/i/search/typeahead.json?count=10&q=%QUERY)?

I'm having troubles in this case, because the _processRemoteSuggestions method, is not able to parse categories, it's made only for non-multidimensional array responses, or strings.

I want to be able to parse a JSON response like { topics: [...], users: [...] }

Do you know if is there a workaround for this?

@jharding
Copy link
Contributor

Supporting something like this is definitely on the roadmap. You should be able to handle this scenario in v0.9 in a roundabout way and in a later version the hope is to add seamless support for it.

@daraosn
Copy link
Contributor

daraosn commented Feb 22, 2013

I'm working on a fix by doing

                    this.transport.get(this.queryUrl, query, this._processRemoteSuggestions(callback, matchedItems).bind(this));

and

            _processRemoteSuggestions: function(callback, matchedItems) {
                return function(data) {
                    var remoteAndLocalSuggestions = {}, dedupedSuggestions = [];
                    if(utils.isArray(data[this.name])) {
                      data = data[this.name];
                    }
...

It works, but transporter only calls _processRemoteSuggestions once, need deeper chances I guess. If I get to fix it, will create a pull request.

@Vidhya-Dilip
Copy link

Vidhya-Dilip commented Apr 12, 2018

In which file should this be added?

<div class="tt-dropdown-menu">
  {{#dataset}}
    <div class="tt-dataset-{{name}}">
      <!-- HEADER GOES HERE -->
      <div class="tt-suggestions">
        {{#suggestions}}
          <div class="tt-suggestion">{{{html}}}<div>
        {{/suggestions}}
      </div>
      <!-- FOOTER GOES HERE -->
  {{/dataset}}
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants