How to initialize selectize with array of objects from server

How to initialize selectize with array of objects from server

INTONEINTONE Posts: 153Questions: 58Answers: 6
edited July 2016 in Editor

how do I initialize selectize with array of objects from server
{ label:'Client', name:'contacts[].contactID', className:'client', type:'selectize' },

I have seen many questions about selectize but none has this use case.

Answers

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin

    In the JSON data structure returned from the initial data fetch made by DataTables include an options object which has a property called contacts[].contactID. That should contain the values you want.

    This example uses select but the same should apply for selectize. Specifically look at the Ajax load tab to see what data has been loaded - right at the bottom you'll see the options.

    Allan

  • INTONEINTONE Posts: 153Questions: 58Answers: 6
    edited July 2016

    Allan,

    Yes I am seeing that there is an:

    ```js

      { "options": 
       "contacts[].contactID": [
          {"label": "Jones, Christopher ", "value": "1"},
          { "label": "Jones, Mark ","value": "3"}] 
     }
    

    ```

  • INTONEINTONE Posts: 153Questions: 58Answers: 6

    The problem is that when I do not use selectize but a simple select it does work as expected. However when I use selectize the data is not loaded but shows like whats in this image: http://www.imageno.com/m9ybqzez9u7hpic.html

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin

    That's really odd - are you able to give me a link to the page so I can debug it please? That looks like it should work to me.

    Thanks,
    Allan

This discussion has been closed.