continuation to select2 edit default value:

continuation to select2 edit default value:

sarath_surisettysarath_surisetty Posts: 54Questions: 13Answers: 0

continuation to https://datatables.net/forums/discussion/52203/editor-select2-ajax-set-default-value

'set' have to be in "opts"?
can i see any example ,below code didnt helped..

{
               "label": "propertyArea",
               "name": "propertyArea.propertyAreaId",
               "type": "select2",
               "data": "propertyArea.propertyAreaName",
               "initialValue":true,
               "set": function (conf, val) {
                   alert("pa out");
               },
               "opts": {
                   "minimumInputLength": 3,
                   "placeholder": 'Property Area',
                   "allowClear": true,
                   "initialValue":true,
                   "set": function (conf, val) {
                       alert("pa in");
                   },
                   ajax: {
                     url: 'propertyArea/json',
                     delay: 250 ,
                     dataType: 'json',
                   //  initialValue:true,

                   data: function (params) {
                       var query = {
                             value: params.term
                         //type: 'public'
                       }

                       // Query parameters will be ?search=[term]&type=public
                       return query;
                     },
                   processResults: function (data) {
                     return {
                         results: $.map(data, function(obj) {
                             return { id: obj.propertyAreaId, text: obj.propertyAreaName };
                         })
                     };
                 }
                   }
              }

Answers

  • colincolin Posts: 15,118Questions: 1Answers: 2,583

    Hi @sarath_surisetty ,

    As Allan said in that thread you linked, it should work. He was asking for a test case so that we can diagnose this. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.