cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

selected rows handler in custom widget building

alexe1
12-Amethyst

selected rows handler in custom widget building

While working on a custom widget I found a bit of quirkiness I thought I'd outline here in case anyone else has the same issue.

My widget takes an infotable property ('Data') the same way that a grid or list or similar widget does. For the sake of simplicity, lets say my widget is just taking in an infotable and displaying a bunch of images. I wanted to be able to select one of the images in my widget by clicking on it, the same way you would for a grid row or something.

Latching onto some click event, I called this.updateSelection() correctly, passing it the propertyname and the index array from the selected row(s). I then noticed that I could only get the "SelectedRowsChanged" event from the data service to fire if I had a grid or some other widget bound to the same source. Same deal with the selected rows data bindings. I was interacting with my widget only, but could only get the full expected functionality if some other row-selectable widget (grid, list, etc) was tied to the same data source service.

After tons of digging, I figured out that you MUST define this.handleSelectionUpdate in your runtime JS, even if you ask it to do absolutely nothing. I didn't need anything to happen in my widget when something was selected, so I left it totally empty. Only then did I get expected functionality out of the data service for selected rows.

TL;DR

you obviously have to call this.updateSelection(propertyName, selectedRowsIndices) when you want to update the row selection

but you NEED this.handleSelectionUpdate = function (propertyName, selectedRows, selectedRowIndices)​ to be defined, even if its empty, to get the full functionality.

ThWx guys, the widget documentation wasn't clear about that at all. It makes it seem like you only need that method defined if you want your widget to change its behavior/look if the selected row changes from some other source. Might be worth updating for clarity. Its like there's some code scrape going on at load looking for what widgets define that method. Does that sound right?

4 REPLIES 4
ttielebein
14-Alexandrite
(To:alexe1)

Can you provide the documentation link to which you are referring?


Thanks for taking the time to post your comments on this!

alexe1
12-Amethyst
(To:ttielebein)

No problem. Took me awhile to figure out what my missing piece was, hopefully someone else doesn't waste the same time.

Someone's PTC support case with pointers to widget documentation - HERE

Actual link to latest widget building documentation as of April 2016 - HERE

ttielebein
14-Alexandrite
(To:alexe1)

Thanks!

Thanks for the info. Really useful.

Announcements


Top Tags