cmv-widgets icon indicating copy to clipboard operation
cmv-widgets copied to clipboard

Search Widget: Search by Shape Functional but NOT by Attributes

Open drusexton opened this issue 6 years ago • 2 comments

@tmcgee So I am trying to allow the Search Widget to enable Search By Attributes and Search by Shape on more than 1 layer in my map service.

The first layer I was able to get the Search by Attributes and Search by Shape function to work. Therefore I simply copied the code, and changed some layer references. However, the Search by Attributes function is not working, yet the Search by Shape is working.

There is no error message, but I do get a message that says no results were returned from the query. Below is my code, any ideas what might be the issue?

{
                name: 'Water Meters',
                expression: '', // additional where expression applied to all queries
                idProperty: 'objectid',
                labelWidth: 110,
                queryParameters: {
                    type: 'spatial', // spatial, relationship, table or database
                    layerID: 'putnamWater', // from operational layers
                    sublayerID: 2,
                    outFields: ['*']
                },
                infoTemplates: {
                    buffer: {
                        title: 'Search Buffer',
                        content: function (feature) {
                            if (feature.geometry) {
                                return number.format(geometryEngine.geodesicArea(feature.geometry, 'acres'), {
                                    places: 2
                                }) + ' Acres';
                            }
                            return '';
                        }
                    }
                },
                attributeSearches: [
                    {
                        name: 'Search for Meter by ID',
                        searchFields: [
                            {
                                field: 'MeterID',
				label: 'Search by Meter ID',
				placeholder: 'Enter a Meter ID (Example: 533)',
                                required: true,
                                expression: '(MeterID LIKE \'[value]%\')',
                                width: 263,
				minChars: 1
                            }
                        ],
                        title: 'Meter Search Results',
                        topicID: 'metersSearch',
			gridOptions: {
                            columns: [
                                {
                                    field: 'MeterID',
				    label: 'MeterID',
				    sortable: true,
				    resizable: false,
				    width: 150
                                },
                                {
                                    field: 'Join_Meters_Name',
				    label: 'Account holder',
                                    sortable: false,
				    resizable: true,
				    width: 150
                                }
                            ]
                        }
                    }
                ]
	},
	{
                name: 'System Valves',
                expression: '', // additional where expression applied to all queries
                idProperty: 'objectid',
                labelWidth: 110,
                queryParameters: {
                    type: 'spatial', // spatial, relationship, table or database
                    layerID: 'putnamWater', // from operational layers
                    sublayerID: 3,
                    outFields: ['*']
                },
                infoTemplates: {
                    buffer: {
                        title: 'Search Buffer',
                        content: function (feature) {
                            if (feature.geometry) {
                                return number.format(geometryEngine.geodesicArea(feature.geometry, 'acres'), {
                                    places: 2
                                }) + ' Acres';
                            }
                            return '';
                        }
                    }
                },
                attributeSearches: [
                    {
                        name: 'Search for System Valves by ID',
                        searchFields: [
                            {
                                field: 'ValveID',
				label: 'Search by Valve ID',
				placeholder: 'Enter a Valve ID (Example: SV-RIR-1)',
                                required: true,
                                expression: '(ValveID LIKE \'[value]%\')',
                                width: 263,
				minChars: 6
                            }
                        ],
                        title: 'SystemValves',
                        topicID: 'svQuery',
			gridOptions: {
                            columns: [
                                {
                                    field: 'ValveID',
				    label: 'System Valve ID',
				    sortable: true,
				    resizable: true,
				    width: 150
                                },
                                {
                                    field: 'Diameter',
				    label: 'Diameter:',
                                    resizable: true,
				    width: 150
                                }
                            ]
                        }
                    }
                ]
            }

drusexton avatar Mar 04 '19 16:03 drusexton

I just wanted to add that the fields being referenced in the layers from the map service are string values, not integer (I changed them per your previous suggestion #203).

drusexton avatar Mar 04 '19 17:03 drusexton

@drusexton Sorry, I've been at the Esri Developer Summit. I'll comment on your issue as soon as I can.

tmcgee avatar Mar 08 '19 04:03 tmcgee