Yes, I think we should try to add these kind of helpful tips to the manual. The Web API is quite extensively covered, but there is still some leap to get started with apps for those of us who are not experienced API + JS developers...
On Wed, Jun 11, 2014 at 9:09 AM, Farai Mutero <fmut...@gmail.com> wrote: > Thanks Knut for raising this question. Now I no longer have to hard code > the root OU UID so as to render the full OU hierarchy in my apps. > > > On Wed, Jun 11, 2014 at 9:07 AM, Knut Staring <knu...@gmail.com> wrote: > >> Thanks! >> >> I now did this, which also works: >> >> var url = dhis_api_base >> +'organisationUnits.json?userDataViewFallback=true'; >> $.getJSON( url, function( json ) { >> console.dir(json.organisationUnits[0].name + ' has UID ' + >> json.organisationUnits[0].id); >> }); >> >> >> On Wed, Jun 11, 2014 at 9:03 AM, Morten Olav Hansen <morte...@gmail.com> >> wrote: >> >>> >>> On Wed, Jun 11, 2014 at 8:50 AM, Knut Staring <knu...@gmail.com> wrote: >>> >>>> $.getJSON( url, function( json ) { >>>> console.dir(json); >>>> }); >>>> >>> >>> $.ajax({ >>> url: URL, >>> dataType: 'json' >>> }).done(function(data) { >>> $.each(data.organisationUnits, function(idx) { >>> console.log("root" + idx + ": " + this.id); >>> }) >>> }); >>> >>> Something like that could work, it returns an array of orgUnits >>> >>> -- >>> Morten >>> >> >> >> >> -- >> Knut Staring >> Dept. of Informatics, University of Oslo >> +4791880522 >> http://dhis2.org >> >> _______________________________________________ >> Mailing list: https://launchpad.net/~dhis2-devs >> Post to : dhis2-devs@lists.launchpad.net >> Unsubscribe : https://launchpad.net/~dhis2-devs >> More help : https://help.launchpad.net/ListHelp >> >> > > > -- > Farai Mutero > > -- Knut Staring Dept. of Informatics, University of Oslo +4791880522 http://dhis2.org
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp