0

I have two lists:

Customers Customers_Documents

The customer list is large -> >10.000 items. When i bind the customer via a lookup field to the Customer_Documents list in general it works, but it is not very user friendly cause of the large amount of items.

Is there a way to use something like SELECT2 or similar to filter/search for items within lookup column?

I need a way without programming, cause i am only able to use OOTB functions like JS, SPDesigner, WebParts etc.

4
  • Using OOTB functions, you're out of luck. Sorry.
    – Nils
    Oct 2, 2016 at 11:47
  • Hm, no luck with SPDesigner, Script Parts, etc.?
    – BOG
    Oct 2, 2016 at 11:59
  • Sure, you could inject some JavaScript (using JSLink, content editor WebPart or SPDesigner) and modify the visualization of the lookup. It wouln't be OOTB, though.
    – Nils
    Oct 2, 2016 at 12:54
  • Ah ok, but if this is possible that would be fine for me. But is this possible? I would also update my question.
    – BOG
    Oct 2, 2016 at 12:56

1 Answer 1

1
<script>
    $(document).ready(function () {
        $("[id*='LookupField']").select2({
            ajax: {
                url: function(params){
                    return "**yourSharepointSiteAddres**/_api/web/lists/GetByTitle('**yourLookupList**')/items?$filter=substringof('"+params.term+"',**yourLookfielYouWantFilter**)";
                }
                ,dataType:'json'
                ,processResults: function (data) {
                    var f='{"results": ['
                        ,counter=0;
                    data.value.forEach(function(ele) {
                        var $f="";
                        if(counter==0)$f="";else $f=",";

                        f+=$f+'{"id":'+ele.ID+',"text":"'+ele.**yourLookfielYouWantFilter**+'"}';
                        counter++;
                    }, this);
                    f+="]}";
                    f=$.parseJSON(f);
                    return f;
                }/// End processResults
            }/// End Ajax request
        });/// End select 2 function
    });//// End Document ready function
</script>

Remove all ** from your code

you can visit this link

https://www.vlieshout.net/tag/select2/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.