Access inside json array

edited July 2015 in Technical questions

I have this json response:

correspondences":[{"id":1,"sys_date":"2015-07-22T00:00:00+0200","name":"name","address":"address","direction_of_correpondence":{"id":1,"sys_date":"2015-07-21T16:34:51+0200","name":"Hyr\u00ebse\/Ulazni\/Incomming"},"subject_matter":{"id":1,"sys_date":"2015-07-21T16:34:51+0200","name":"K\u00ebrkes\u00eb p\u00ebr p\u00ebrgjigje n\u00eb ankes\u00eb\/Zahtev za odgovor na \u017ealbu\/Notification of alleged perpetrators"},"annexes_nr":1,"annexes_type":"pdf","date_and_time":"2015-07-22T00:00:00+0200","date_of_expiration":"2015-07-23T00:00:00+0200","date_sent":"2015-07-24T00:00:00+0200","decision_by":{"id":1,"sys_date":"2015-07-21T16:34:51+0200","name":"Vendimi i PZAP-it\/Odluka IP\u017dP-a\/ECAP Decision"},"documents":[]},

{"id":3,"sys_date":"2015-07-14T00:00:00+0200","name":"name","address":"address","direction_of_correpondence":{"id":2,"sys_date":"2015-07-21T16:34:51+0200","name":"Dal\u00ebse\/Izlazni\/Outgoing"},"subject_matter":{"id":2,"sys_date":"2015-07-21T16:34:51+0200","name":"P\u00ebrgjigje n\u00eb ankes\u00eb\/Odgovor na \u017ealbu\/Explanation from alleged perpetrators"},"annexes_nr":1,"annexes_type":"annexes_type","date_and_time":"2015-07-24T00:00:00+0200","date_of_expiration":"2015-07-24T00:00:00+0200","date_sent":"2015-07-24T00:00:00+0200","decision_by":{"id":1,"sys_date":"2015-07-21T16:34:51+0200","name":"Vendimi i PZAP-it\/Odluka IP\u017dP-a\/ECAP Decision"},"documents":[]}],"case_status":{"id":1,"name":"Duke pritur koment\/\u010cekanje za koment\/Waiting for Comment","sys_date":"2015-07-21T16:34:51+0200"}}

How can i populate datatable with both of these data with id=1 and id=3 with one single request.

I have tried {width:20, header:"#", map:"#correspondences[].id#",adjust:true}, for populating first column but it doesn't work.
When I try {width:20, header:"#", map:"#correspondences[0].id#",adjust:true}, shows only first object.

I want to show all objects inside this collection(array).

Any Idea?

Thank you.

Comments

  • You need to provide an array of objects as data

    Something like next

        { view:"datatable",
         autoConfig:true,
         data:data.correspondences }
    

    http://webix.com/snippet/bd3b112b

  • Thanks Maksim for the answer as always, but I tried to get array of objects as data like this:

    var thedata = webix.ajax("app_dev.php/api/secure/cases/"+caseid).then(function(data){
    return data.json().correspondences;
    });

    and then in datatable I wrote like this :
    { view:"datatable",
    autoConfig:true,
    data:thedata

    but error that is returning to me is : Uncaught RangeError: Maximum call stack size exceeded.

    Any idea what can be the problem. This happens to me only when I write this code above.

    Thank you very much

  • I have tried the same code locally and it works for me

    webix.ui({
                    view:"datatable",
                    autoConfig:true,
                    height:600, width:800,
                    data:webix.ajax("data.json").then(function(data){
                        return data.json().correspondences;
                    })
                }); 
    
  • Thank you maksim it works for me as well.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion