i want to group returned json data by libelle i end up with the following
script :
$('.membre').select2({
        placeholder: 'Select an item',
        ajax: {
          url: '/select2-autocomplete-ajax',
          dataType: 'json',
          delay: 250,
          data: function (params) {
            return {
              membre_id: params.term // search term
            };
          },
          processResults: function (data) {
            return {
              results:  $.map(data, function (item) {
                    return {
                        text: item.libelle,
                        children: [{
                        id: item.id,
                        text: item.nom +' '+ item.prenom
                        }]
                    }
                })
            };
          },
          cache: true
        }
});
is there any possibility to make the group work properly without repeating the libelle ?
JSON output :
[{"id":1,"libelle":"Laboratoire Arithm\u00e9tique calcul Scientifique et Applications","nom":"jhon","prenom":"M"},{"id":2,"libelle":"Laboratoire Arithm\u00e9tique calcul Scientifique et Applications","nom":"JHON","prenom":"jhon"}]

 
    