Hi every one, I'm working in cmv map viewer, i have layer with related records, so i need to query using related data, how i can do that ?
layer A related to table B using pk--> fk
Query will done in table B and results appear in grid afterthat when click on record zoom to it.
thanks for all
Solved! Go to Solution.
Think like, you are queying tableB with a relation/linkedQuery to LayerA. and not the other way around. Without you sharing you configuration, I cannot confirm but,your configuration should look something like below
//only the layers section layers: [{ name: "LayerA&TableB", . . queryParamerters:{ type:"table", url: "<tableB url>", . . }, attributeSearches:[{ name: "Search for TableB fields", searchFields: [{tableBField options}], gridOptions: { columns: [], sort: [] } }], linkedQuery: { url: "<LayerA url>", type: "spatial", //you could probably use more of the queryParameters options like outfields etc idProperty: "pk field", ids: [] } }]
How are you displaying the table? Are you using the user contributed widget "AttributeTable" or "Search widget" ?
Using Search widget
You can use the linkedQuery option to do that. This option is part of AttributeTable. But you can add it to the search layer or attributeSearches properties depending on your configurations for the search. If you add it to layer, it will apply for all attributeSearches, or you can have different one for each attributeSearches. so your configuration should have something like below.
the layer will contain the table B details and the linkedQuery will contain layer A details. I hope the pk and fk are same names.
linkedQuery: {
url: layer A url,
idProperty: fk,
ids: [] // if linkedQuery, then store the linkedIDs for use in linked query
},
Hope this works out.
Thank you for your replay, do you mean used this widget
cmv-widgets/README.md at master · tmcgee/cmv-widgets · GitHub
in my application?
In a way yes, the Search Widget in the below link already uses the "Attribute Table" widget (its a dependency for Search Widget).
cmv-widgets/widgets/Search at master · tmcgee/cmv-widgets · GitHub
Thank you for replaying, can give me complete example to apply it
I don't have the set or the layer table relation. If you attach you config file with search configuration, updated to best of you knowledge. I could look and fix/add the linkQuery for you. Or @Tim McGee can help you.
Ok, i need to ask how I can search in fields from table (B) not in Layer (A).
Thanks
Up