jsondojojsonreststore

Dojo FilterSelect not populated by JsonRest


Hi I have the following

 <script type='text/javascript'>if (dijit.byId('assignedUserId') != undefined) {
   dijit.byId('assignedUserId').destroy();}require([  'dojo/store/JsonRest',    
 'dijit/form/FilteringSelect',  'dojo/domReady!'], function(JsonRest, FilteringSelect){   
  var jsonRest =      new JsonRest({      target: 'Welcome.do?call=JS&actionRefId=142'    });
  var filteringSelect = new      FilteringSelect({        id: 'assignedUserId',        name: 
 'assignedUserId',        value: '25',             store: jsonRest,        searchAttr: 'name', 
 labelAttr: 'label'    },      'assignedUserIdSelect').startup();});
 </script>
 <input id='assignedUserIdSelect' name='value(assignedUserId)'/>

When I start typing into the filteringselect it calls the URL and returns

 {"identifier": "id", "label": "label", "items": [{ "name": "", "id": "0" , "label": "" },{   
 "name": "Lea M Test", "id": "26" , "label": "Lea M Test" }]}

but nothing is populated into the filtering select - what is the format of the json that needs to be returned by the server?


Solution

  • Try returning an array of objects. Quick test is to modify your JsonRest target to be a simple php file. If your server processes '.php' files, for example, create a file named something like Welcome.php with the following contents:

    <?php
      $data = '[{ "name": "Abi Normal", "id": "0" , "label": "Abi Normal" },{"name": "Lea M Test", "id": "26" , "label": "Lea M Test" }]';
      echo $data;
    ?>
    

    Then change your JsonRest target to be Welcome.php