select2+editor+edit set intial value or default value.

select2+editor+edit set intial value or default value.

sarath_surisettysarath_surisetty Posts: 54Questions: 13Answers: 0

Hi Allan

i have implemented select2 successfully for editor , worked as expected for "create" option,
but problem is the edit form does not update with value to the select2.

     {
                      "label": "Area",
                      "name": "Area.AreaId",
                      "type": "select2",
                      "data": "Area.AreaName",
                      "initialValue":true,
                      "opts": {
                          "minimumInputLength": 3,
                          "placeholder": 'Area',
                          "allowClear": true,
                          //"initialValue":true,
                          ajax: {
                            url: 'Area/json',
                            delay: 250 ,
                            dataType: 'json',
                          //  initialValue:true,

                          data: function (params) {
                              var query = {
                                    value: params.term

                              }

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

Response :

{"id":47,"text":"newyork"}

this might be my last question for you.
thanks alot for support

regards
sarath

Answers

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

    I'm not quite understanding I'm afraid. Can you give me a link to a page showing the issue please?

    Are you expecting the JSON return you mentioned to update the list of options in Select2?

    Allan

  • sarath_surisettysarath_surisetty Posts: 54Questions: 13Answers: 0

    cannot give link as it is in localhost:

    ->when we select row and click on edit, the form in modal has select2 which is supposed populate value from selected row, like how other fields like textinput is getting populated.

    ->select2 is making an ajax call to get results.
    Please find the screen shot when i click on edit button for the selected row.

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

    This sounds a lot like your other thread. Is it the same issue?

    I really would need a test case to be able to debug it I'm afraid. Can you publish your page on the web somewhere please?

    Allan

This discussion has been closed.