jQWidgets Forums

jQuery UI Widgets Forums Grid Unable to access nested JSON data returned from dataAdapter

This topic contains 1 reply, has 1 voice, and was last updated by  vincentvega 12 years, 1 month ago.

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

  • vincentvega
    Member

    I am new to jqWidgets

    In order to minimize server side calls, I have a relatively complex JSON array that embeds other JSON arrays
    that I am able to succesfully retrieve from 1 server side call using the $.jqx.dataAdapter. JSON structure looks like this:

    {
    orderData: [{key1:value1, key2:value2,...},{key3:value3, key4:value4...},....],
    locationData: [{key1:value1, key2:value2,...},{..},...]
    .
    .
    .
    }

    I am able to successully use the “orderData” array in the above JSON array of arrays to fill a jqGrid.
    There is a simple html table (header for the jqGrid)just above the jqGrid div tags that I am unable to fill
    with the “locationData” JSON array data. I am attempting to pass the “data” object to a javascipt function
    that would in turn attempt to populate a span tag with data using dot notation. Am I missing something? Plase
    advise on how to accomplish this.

    var dataAdapter = new $.jqx.dataAdapter(source, {
    downloadComplete: function (data, status, xhr) {
    //alert('complete:'+JSON.stringify(data));
    alert("data.locGeoData: "+JSON.stringify(data.locGeoData));
    },
    loadComplete: function (data) {
    //var records = dataAdapter.records;
    //var length = records.length;
    //alert("eaData: \n"+records+"\n"+length);
    prepareHeader(data);
    }

    .
    .
    .

    	function prepareEAHeader(data){
    //alert("data: "+data);
    $('#headerText1').text(data.locationData.key1);
    $('#headerText2').text(data.locationData.key2);
    }

    .
    .
    .

    	<td><span id="headerText1"></span></td>

    .
    .
    .

    	<td><span id="headerText2"></span></td>

    vincentvega
    Member

    I was able to figure this out…should have been referencing the array element in the basic jQuery calls like so….

    $('#headerText1').text(data.locationData[0].key1);
    $('#headerText2').text(data.locationData[0].key2);
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.