querying a related table

2605
6
Jump to solution
10-26-2014 01:30 PM
joepublic
New Contributor III

I'm trying to rewrite my esri-leaflet app to use the related tables plugin. (see attached)

I'm trying to query the table by clicking on a button (upper left above the map).

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Joe,

  I submitted an Issue to John on the problem I am seeing with the relationshipIds vs relationshipId. We will have to see what he says. It seems like an ArcGIS Server version compatability issue as relationshipIds works with ArcGIS Server 10.22 like his sample is using but does not work with 10.11 like you are using. You can use the workaround of changing the esri-leaflet-related.js as follows (line 7):

L.esri.Tasks.QueryRelated = L.esri.Tasks.Task.extend({

  setters: {

    'offset': 'offset',

    'limit': 'limit',

    'outFields': 'fields[]',

    'objectIds': 'objectIds[]',

    'relationshipId': 'relationshipId',

And then this code will work for you:

        $('#NSM').click(function(evt){

            $('#sidecol').empty();

            buttonPicked = 'NSM';

            buttonType = document.getElementById('NSM');

           

            var query = L.esri.Tasks.query(tableURL).where("type like '" + buttonType.value + "'");

            var rquery = L.esri.Tasks.queryRelated(tableURL).relationshipId("0");

            query.ids(function(error, ids, response){

              rquery.objectIds([ids.join(',')]);

              rquery.run(function(error, response, raw){

                  console.log(error);

                  console.log(response);

              });

            });

        })

View solution in original post

0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus

Joe,

   There are several *.js files missing from your zip file. It would a lot easier to help if all files where present.

0 Kudos
joepublic
New Contributor III

I've uploaded the esri related table library file

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Joe,

   Did you write the esri-leaflet-related.js? Because there is not a relationshipIds parameter on the related features query that takes an array it is relationshipId and take a single related id.

0 Kudos
joepublic
New Contributor III

Robert,

It's a recently created esri-leaflet plugin

https://github.com/jgravois/esri-leaflet-related

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Joe,

  I submitted an Issue to John on the problem I am seeing with the relationshipIds vs relationshipId. We will have to see what he says. It seems like an ArcGIS Server version compatability issue as relationshipIds works with ArcGIS Server 10.22 like his sample is using but does not work with 10.11 like you are using. You can use the workaround of changing the esri-leaflet-related.js as follows (line 7):

L.esri.Tasks.QueryRelated = L.esri.Tasks.Task.extend({

  setters: {

    'offset': 'offset',

    'limit': 'limit',

    'outFields': 'fields[]',

    'objectIds': 'objectIds[]',

    'relationshipId': 'relationshipId',

And then this code will work for you:

        $('#NSM').click(function(evt){

            $('#sidecol').empty();

            buttonPicked = 'NSM';

            buttonType = document.getElementById('NSM');

           

            var query = L.esri.Tasks.query(tableURL).where("type like '" + buttonType.value + "'");

            var rquery = L.esri.Tasks.queryRelated(tableURL).relationshipId("0");

            query.ids(function(error, ids, response){

              rquery.objectIds([ids.join(',')]);

              rquery.run(function(error, response, raw){

                  console.log(error);

                  console.log(response);

              });

            });

        })

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Joe,

   If you check back on the GitHub Site John has accepted the bug and fixed it as I already described.

0 Kudos