green3g / cmv-widgets

Dojo Widgets to extend the functionality of CMV
https://roemhildtg.github.io/cmv-widgets/
MIT License
19 stars 29 forks source link

Relateion table does not work for dynamic layers #30

Closed mtabdar closed 7 years ago

mtabdar commented 7 years ago

Hi Thanks for the amazing widgets espcially the relation table. It is fantastic but i couldn't use it with my dynamic layers. is it a bug or i am doing something wrong?

green3g commented 7 years ago

Nope, its not a bug, its just a limitation of the widget. It uses Feature layer "clicks" to do the query. I do have an example of it working with dynamic layers though, but it works a little differently. It uses the identify popup to display the table instead. Would that meet your needs?

https://github.com/roemhildtg/cmv-widgets/tree/master/widgets/RelationshipTable#include-in-identify-popup

mtabdar commented 7 years ago

Thanks. In fact it is exactly what i want but i cannot do it! I used your samples just changed the urls to my own. Then i set identify to show relation tables it workd fine for "petrolium" (why is it not petroleum?) which is feature layer but couldndo the same for timekansas which is dynamic. I also changed petroleum to dynamic and the identify stopped showing relation table.!!?

green3g commented 7 years ago

Does the identify show up at all? Or are there error messages?

mtabdar commented 7 years ago

Yes identify shows regular identify values and no errors just some svg.js errors which are not related to this.

green3g commented 7 years ago

Off the top of my head, it sounds llike your layer id might not match up with your identify layer id.

In viewer.js (or main cmv config file), what is:

In identify.js config file, what is:

For example, I have a dynamic layer:

        {
            id: 'assets',
            type: 'dynamic',
            url: '/arcgis/rest/services/internal/assets/MapServer',
            title: 'Assets and Utilities',
            options: {
                id: 'assets'
            },
            layerControlLayerInfos: {
                expanded: true
            }
        }

and my identifies info looks like this:

identifies: {
    assets: {
            25: {
            title: 'Street Segmenet {cid}',
            content: factory([{
                title: 'History',
                objectIdField: 'OBJECTID',
                relationshipId: 4,
                url: '/arcgis/rest/services/internal/assets/MapServer/25',
                columns: [{
                    field: 'Operation'
                }, {
                    field: 'op_year',
                    label: 'Year'
                }]
            }])
        },
    }
}
green3g commented 7 years ago

Similarly, for feature layers, the only thing you'd need to change is this in viewer.js:

{
            id: 'assets',
            type: 'feature',
            url: '/arcgis/rest/services/internal/assets/MapServer/25',
            title: 'Assets and Utilities',
            options: {
                outFields: '*',
                id: 'assets'
            },
            layerControlLayerInfos: {
                expanded: true
            }
        },
mtabdar commented 7 years ago

Yes you are right. When i checked and corrected sublayer id's and relation id's i could see the related records in identify for dynamic layer. Thanks. Though i have 2 problems

  1. My layer with id =0 doesn't show the related records
  2. Although i have set a 1:M relationship and provided several records in the table for each objectid, only one record is shown as the result.
green3g commented 7 years ago

There's a fix for number 1, it is a bug in the identify widget: https://github.com/cmv/cmv-app/pull/706

For number 2, it might be helpful for you to look at the network logs when you do the identify. Then you can see what query is being passed to the server, and what it is returning as a response.

mtabdar commented 7 years ago

thanks. 1- i think you are right about "layer with id =0" because i encountered some other issues with it (label layers for example) but unfortunately i couldn't understand if there is a fix available or the root of the problem is identified and you are trying to fix it? 2- again you are right and i should investigate more about it. thanks a lot for the help.

green3g commented 7 years ago

The problem is identified, but has not been included in cmv-app yet. The only change that needs to happen is in gis/dijit/Identify.js https://github.com/cmv/cmv-app/blob/64b0a2fbdc07fcb7652cc8d75aac205729a341a2/viewer/js/gis/dijit/Identify.js#L400

green3g commented 7 years ago

This fix is now in the cmv develop branch. You should be able to download the latest version and have this issue resolved.