1

I've created a CMV query widget that I am trying to link up with the Attribute Table widget. The table tab is being created in the bottom pane but that's as far as I'm able to get. I'm unable to get the query to actually execute and I'm unsure of the reason. I have used the Search widget as my starting point.

In my executing function I have the following:

var query = {
    "layerID": "SelectOverlayData",
    "sublayerID": 1,
    "type": "spatial",
    "outFields": [
        "TMK",
        "TPL_ACRES",
        "owner",
        "B_al02"
    ],
    "outputSpatialReference": {
        "wkid": 102100,
        "latestWkid": 3857
    },
    "spatialRelationship": "esriSpatialRelIntersects",
    "geometry": null,
    "where": "TPL_ACRES <= 40 AND B_al02 = 'Yes'"
};

and

var grid = {
    "minWidth": 50,
    "columns": [
        {
            "field": "TMK",
            "label": "Parcel ID",
            "width": 100
        },
        {
            "field": "TPL_ACRES",
            "label": "Acres",
            "width": 100
        },
        {
            "field": "owner",
            "label": "Owner",
            "width": 100
        },
        {
            "field": "B_al02",
            "label": ">>Protect farmlands",
            "width": 100
        }
    ],
    "sort": [
        {
            "attribute": "TMK",
            "descending": "ASC"
        }
    ],
    "defaultColumnWidth": 100,
    "columnHide": true,
    "columnReorder": true,
    "pagination": true,
    "paginationOptions": {
        "rowPerPage": 50,
        "previousNextArrows": true,
        "pagingLinks": 2,
        "pagingTextBox": true,
        "showLoadingMessage": true
    }
};

Into

        topic.publish(this.attributesContainerID + '/addTable', {
            title: layer.name,
            topicID: this.topicID,
            queryParameters: query,
            gridOptions: grid,
            idProperty: layer.idProperty
        });

The tab is created in the bottom pane with the rest of the Attribute Table widget but the query is never run (nothing in the Network tab of Chrome) and no records or columns ever appear in the table. No js errors. I must be missing something small.

Any help?

1

From a quick glance, your configuration looks correct. You can omit the geometry property for the query but that should not influence the success or failure.

The most common reason for the query not executing and not receiving an error message is that the url for the query is wrong or cannot be determined from the layer using layerID and sublayerID. I recommend that you use Chrome Dev Tools to step through the executeQuery (https://github.com/tmcgee/cmv-widgets/blob/master/widgets/AttributesTable/_QueryMixin.js#L107) and buildURL (https://github.com/tmcgee/cmv-widgets/blob/master/widgets/AttributesTable/_QueryMixin.js#L107) functions and see where it might be falling over.

The other possibility is that you have an incorrect field name and the QueryTask is returning an error. This error should be caught and appear as a growl in the Growler widget (Assuming you have that widget in your app).

  • So does the topic addTable publish to the topic executeQuery? It looks to me like the addTable topic adds the table and publishes to topic tableAdded and then that's it. Do I then need to publish to executeQuery? – asyncgis Mar 18 '15 at 15:16
  • No you do not need to publish the second topic. I was referring to the executeQuery method. – tmcgee Mar 18 '15 at 15:22
  • So should this be published to executeQuery rather than addTable? topic.publish(this.attributesContainerID + '/addTable', { title: layer.name, topicID: this.topicID, queryParameters: query, gridOptions: grid, idProperty: layer.idProperty }); – asyncgis Mar 18 '15 at 15:43
  • No. addTable will also execute the query if the query parameters are valid. Double check your parameters as I noted in my answer. – tmcgee Mar 18 '15 at 15:45
  • Sorry Tim, I'm new to the Dojo topic stuff and still trying to wrap my brain around that. I'm trying to follow the program flow from addTable through executeQuery so I can see where my queryParameters are not passing the test. I appreciate your time. – asyncgis Mar 18 '15 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.