jQWidgets Forums

jQuery UI Widgets Forums Plugins Data Adapter XML or JSON

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 10 years, 8 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    XML or JSON Posts
  • XML or JSON #60470

    binfch
    Participant

    Hello

    I am using Wave Framework as PHP backend. I get the data back as JSON or XML. I’d like to show the data in a ComboBox and tried several settings at the DataAdapter level but still it is not working. Any idea what i am doing wrong?

    My code:

            <script type="text/javascript">
                $(document).ready(function () {
    				var source = {
    					datatype: "json",
    					datafields: [
    						{ name: 'aktion_id' },
    						{ name: 'beschreibung_en' }
    					],
    					id: 'aktion_id',
    					url: 'http://localhost/web2eims/api/json.api?www-command=project-all'
    				};
    				var dataAdapter = new $.jqx.dataAdapter(source);			
                    $("#jqxdropdownlist").jqxDropDownList({ source: dataAdapter, selectedIndex: 0, width: '200px', height: '25px' });
                });
            </script>
    

    The JSON data I get back looks like:

    {"www-message":"Request complete","www-response-code":500,"0":{"aktion_id":"1","beschreibung_en":"RIA - Research & Innovation Action"},"1":{"aktion_id":"2","beschreibung_en":"IA - Innovation Action"},"2":{"aktion_id":"3","beschreibung_en":"CSA - Coordination & Support Action"},"3":{"aktion_id":"4","beschreibung_en":"MSCA - Marie Sklodowska-Curie Action"},"4":{"aktion_id":"5","beschreibung_en":"ERC - Grants"},"5":{"aktion_id":"6","beschreibung_en":"PRI - Prices"},"6":{"aktion_id":"7","beschreibung_en":"SME - Instruments"},"7":{"aktion_id":"8","beschreibung_en":"FTI - Fast Track to Innovation"},"8":{"aktion_id":"9","beschreibung_en":"MSCA - Cofund"},"9":{"aktion_id":"10","beschreibung_en":"ERA\/NETs"},"10":{"aktion_id":"11","beschreibung_en":"PCP - Pre-Commercial Procurement"}}
    

    I could also use the XML data:

    <www>
    <www-message>Request complete</www-message>
    <www-response-code>500</www-response-code>
    <node>
    <aktion_id>1</aktion_id>
    <beschreibung_en>RIA - Research & Innovation Action</beschreibung_en>
    </node>
    <node>
    <aktion_id>2</aktion_id>
    <beschreibung_en>IA - Innovation Action</beschreibung_en>
    </node>
    <node>
    <aktion_id>3</aktion_id>
    <beschreibung_en>CSA - Coordination & Support Action</beschreibung_en>
    </node>
    <node>
    <aktion_id>4</aktion_id>
    <beschreibung_en>MSCA - Marie Sklodowska-Curie Action</beschreibung_en>
    </node>
    <node>
    <aktion_id>5</aktion_id>
    <beschreibung_en>ERC - Grants</beschreibung_en>
    </node>
    <node>
    <aktion_id>6</aktion_id>
    <beschreibung_en>PRI - Prices</beschreibung_en>
    </node>
    <node>
    <aktion_id>7</aktion_id>
    <beschreibung_en>SME - Instruments</beschreibung_en>
    </node>
    <node>
    <aktion_id>8</aktion_id>
    <beschreibung_en>FTI - Fast Track to Innovation</beschreibung_en>
    </node>
    <node>
    <aktion_id>9</aktion_id>
    <beschreibung_en>MSCA - Cofund</beschreibung_en>
    </node>
    <node>
    <aktion_id>10</aktion_id>
    <beschreibung_en>ERA/NETs</beschreibung_en>
    </node>
    <node>
    <aktion_id>11</aktion_id>
    <beschreibung_en>PCP - Pre-Commercial Procurement</beschreibung_en>
    </node>
    </www>
    
    XML or JSON #60477

    Peter Stoev
    Keymaster

    Hello binfch,

    The dataAdapter is not initialized correctly. That’s wrong in this code. Your data is stored in array “0”, but this is not pointed out in the dataAdapter’s initialization. I think that you should set the dataAdapter’s “root” setting, too.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.