Datatable Select2

Datatable Select2

Tabraiz FehamTabraiz Feham Posts: 3Questions: 2Answers: 0

How can we make select2 dynamic select with ajax using that plugin try to use that extension but no any option or example mention for ajax based data options.

https://editor.datatables.net/plug-ins/field-type/editor.select2

Is that any example your fetching options dynamically any help appreciated.

Answers

  • Tabraiz FehamTabraiz Feham Posts: 3Questions: 2Answers: 0

    @allan plz help me out to sort out the issue

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    You can pass any Select2 option directly to Select2 by using the opts property of the field. e.g.:

     {
       "label": "State:",
       "name": "state",
       "type": "select2",
       "opts": {
           "placeholder": "Select State",
           "allowClear": true
       }
    }
    

    You can also pass through Select2's Ajax configuration options in that same way.

    Allan

  • rizwansultan88rizwansultan88 Posts: 7Questions: 2Answers: 0


    @allan I'm also facing same issue datatable show select2 items but css out and not triggering save event one more thing I want to know how we render selected value in datatable is that select method work for it. I don't want to render javascript during runtime any work around or running example.

    You're quick help appreciated.


    { data: "ItemType" , render: function ( data ) { if(data==0){ return "--"; } return OtherTypeJs[ data ]; } }
  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    I'm also facing same issue datatable show select2 items but css out and not triggering save event one

    Can you give me a link to a page showing the issue please?

    one more thing I want to know how we render selected value in datatable is that select method work for it.

    If the data to show in the table is available in the data source object for the row, you would do it with columns.data, just like in this example.

    Allan

This discussion has been closed.