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

[Search] Allow custom display fields #2645

Closed
wants to merge 1 commit into from

Conversation

anibalmf1
Copy link
Contributor

This change allow the developter to choose the field to display in the results. So we don't have to change our json's object field names to the fixed ones (title, price and description).
usage:

$('div[name="searchDiv"]').search({
source: [{id:0, myfield: 'some text', extrafield: 'ST'}, {id:1, myfield: 'another text', extrafield: 'AT'}],
searchFields: [
myfield
],
displayField: extrafield
});

This change allow the developter to choose the field to display in the results. So we don't have to change our json's object field names to the fixed ones (title, price and description).
usage:

$('div[name="searchDiv"]').search({
            source: [{id:0, myfield: 'some text', extrafield: 'ST'}, {id:1, myfield: 'another text', extrafield: 'AT'}],
            searchFields: [
                myfield
            ],
            displayField: extrafield
        });
@jlukic jlukic added this to the 2.1 milestone Jul 16, 2015
@jlukic
Copy link
Member

jlukic commented Jul 16, 2015

Thanks I'll review this with 2.1. I think this is a good idea though.

@jlukic jlukic changed the title Update search.js to allow custom display fields [Search] Allow custom display fields Aug 11, 2015
@jlukic
Copy link
Member

jlukic commented Aug 17, 2015

I've decided to implement this in a slightly different way, but the gist is the same.

@jlukic
Copy link
Member

jlukic commented Aug 17, 2015

All server fields are now a setting and can be modified at will.

I've added examples to the docs as well on how to do this.

Here's a quick fiddle to demo.
http://jsfiddle.net/npyfwkLa/

@jlukic jlukic closed this Aug 18, 2015
@anibalmf1
Copy link
Contributor Author

Nice work man... Congrats.

jlukic added a commit that referenced this pull request Aug 18, 2015
@jlukic
Copy link
Member

jlukic commented Aug 18, 2015

Added to dropdown with remoteData as well

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

Successfully merging this pull request may close these issues.

3 participants