Select to view content in your preferred language

Issues in sample code: Synchronize FeatureTable highlights and selection

398
8
Jump to solution
08-09-2024 02:28 PM
ForrestLin
Frequent Contributor

I'm going through the sample code: Synchronize FeatureTable highlights and selection

https://developers.arcgis.com/javascript/latest/sample-code/widgets-featuretable-row-highlights

1. There is no method highlight in LayerView

ForrestLin_1-1723238298546.png

https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html#metho....

ForrestLin_4-1723238674268.png

2. There is no method ignoreAbortErrors in promiseUtils

ForrestLin_2-1723238472899.png

https://developers.arcgis.com/javascript/latest/api-reference/esri-core-promiseUtils.html#methods-su...

ForrestLin_3-1723238532368.png

I use Angular/TypeScript and get build errors.

Thanks.

Forrest

 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
mleahy_cl
Regular Contributor

You could try casting the LayerView as a FeatureLayerView.  That type has the highlight method.

(Edit: I don't know about the promiseUtils issue...maybe someone else can answer that)

View solution in original post

0 Kudos
8 Replies
mleahy_cl
Regular Contributor

You could try casting the LayerView as a FeatureLayerView.  That type has the highlight method.

(Edit: I don't know about the promiseUtils issue...maybe someone else can answer that)

0 Kudos
ForrestLin
Frequent Contributor

@mleahy_cl 

Casting the LayerView as a FeatureLayerView works.

Thank you!

0 Kudos
ForrestLin
Frequent Contributor

I debug into JavaScript

https://developers.arcgis.com/javascript/latest/sample-code/widgets-featuretable-row-highlights

ForrestLin_0-1723470264263.png

There is promiseUtils.ignoreAbortErrors:

ForrestLin_1-1723470361609.png

But I get error in TypeScript:

ForrestLin_2-1723470571820.png

 

0 Kudos
mleahy_cl
Regular Contributor

I'm not sure what that method does (I might guess it disables logging abort errors from HTTP requests to the console).  But as you've observed, it's not a documented method of promiseUtils.

With that in mind, even though we can see/use the method through the dev console, my own preference would be to ignore that it exists, unless I had some other confirmation (i.e., from Esri documentation) that the method is not going to change or go away in a future version of the SDK. 

 

 

0 Kudos
ForrestLin
Frequent Contributor

@mleahy_cl 

 promiseUtils.ignoreAbortErrors in JavaScript

https://developers.arcgis.com/javascript/latest/sample-code/widgets-featuretable-row-highlights

ForrestLin_0-1723574320057.png

I need the same code, but it doesn't work in TypeScript.

 

Thanks.

Forrest

0 Kudos
ForrestLin
Frequent Contributor

@mleahy_cl 

 promiseUtils.ignoreAbortErrors in JavaScript

https://developers.arcgis.com/javascript/latest/sample-code/widgets-featuretable-row-highlights

ForrestLin_0-1723574725051.png

ForrestLin_1-1723574771899.png

 

I need the same code, but it doesn't work in TypeScript.

 

Thanks.

Forrest

0 Kudos
mleahy_cl
Regular Contributor

If you want to follow that example, you can side-step the issue in typescript by casting (at least temporarily) the promiseUtils object as `any`, and call the `ignoreAbortErrors()` method through that - like so: `(<any>promiseUtils).ignoreAbortErrors();`

That said, the lack of documentation for the method (as far as I can see) and its absence from the typescript interface for the SDK would make me hesitate to rely on the method.  If you do the above, I'd be at least cautious when you upgrade to a newer version of the SDK, as an undocumented method like that could behave differently or be removed entirely from the SDK.

That's just my view, anyway...unless someone else from Esri speaks up here and suggests otherwise.

0 Kudos
ForrestLin
Frequent Contributor

@mleahy_cl 

Thank you for your suggestion!

I tried to use promiseUtils.isAbortError, instead of promiseUtils.ignoreAbortErrors. It looks like working.

view.on("pointer-move", (event: ViewPointerMoveEvent) => {
        //promiseUtils.ignoreAbortErrors(highlightOnViewHover(event));
        highlightOnViewHover(event).catch((err) => {
          if (!promiseUtils.isAbortError(err)) {
            throw err;
          }
        });
      });

 

Forrest

0 Kudos