Implementing Select2 jQuery pluggin with datatables

Implementing Select2 jQuery pluggin with datatables

kirisafarkirisafar Posts: 3Questions: 0Answers: 0
edited March 2013 in Editor
Hi guys,

I'm working on a internal CMS and I'm trying to implement select2 (http://ivaynberg.github.com/select2/) and datatables specifically with the editor plugin.

I've managed to have them working separately on the same page but how do I go to get the select box inside the envelope form?

Replies

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin
    Hi kirisafar,

    I see your Editor trial is over how. How did you get on with it? Hopefully well if you are planning to continue using it here! All feedback is always welcome.

    To answer your question, you would use a field type plug-in, as described in this tutorial: https://editor.datatables.net/tutorials/field_types . That would create a wrapper around select2 which Editor can use.

    Regards,
    Allan
  • kirisafarkirisafar Posts: 3Questions: 0Answers: 0
    Hey Allan,

    Thank you, I didn't expect that quick a reply from you, that's awesome! I'm pushing to have datatables in our CMS and then we would need a multiple developer license. For that I need to create a Vulnerability Assessment report: Are there any documented vulnerabilities in your plugin?

    Thank you so much again.
  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin
    > Are there any documented vulnerabilities in your plugin?

    Not as far as I am aware. There was a vulnerability in TableTools 2.1.4- whereby an injection attack could read local cookies etc, but that has been patched in the 2.1.5 release. I'm not aware of any issues in the current releases of the software.

    I hope this helps, but do let me know if you have any other questions.

    Regards,
    Allan
  • nisofnisof Posts: 5Questions: 0Answers: 0
    maybe this is too late - but select2 is really easy if you just need single selects. add this to the editor events
    "onOpen" : function(json, data) {
    $("#DTE_Field_dept\\.id").select2({
    'placeholder' : "Select options",
    'dropdownAutoWidth':'false',
    'minimumResultsForSearch':'-1'
    });
  • jpgnzjpgnz Posts: 4Questions: 1Answers: 0
    edited May 2014

    Is it possible to elaborate on this a bit with a working example? Trying to figure out how it fits together, links in thread are dead.

    ---- edit ----

    Never mind, sorted it. FYI:

    editor.on('onOpen', function(e) {
        $('#DTE_Field_salary').select2({
            ajax: {
                dataType: "json",
                url: "/assets/js/datatables/moredummy.json",
                results: function (data) {
                    return {results: data};
                }
            }
        });
    
    });
    
    // /assets/js/datatables/moredummy.json
    [ {"id": 1, "text": "option1"},
      {"id": 2, "text": "option2"},
      {"id": 3, "text": "option3"} ]
    
This discussion has been closed.