Skip to main content
May 23, 2020 3:32 PM UTC
Solved

How to set the "Selected Row(s)" in custom widget ?

Hi, 

I created a custom table widget ,  the widget can bind data and display well .  When the table row get selected , I can get the selected row(s),  but  how can I set the  rows to  the binding service's "Selected Row(s)" ?

 

I can defined a JSON property as selected value,  but I prefer the standard mashup  binding style for selected rows. 

 

seanccc_0-1590247876171.png

 

Regards,

Sean

 

May 24, 2020 9:38 AM UTC

I think something like:

// -- yourWidget it's the javascript instance of your widget
// -- Where 'Data' it's the name of the infotable property on your widget
// -- [array..] --> if you have single select, something like [3] or multi select [0,3,8]
yourWidget.updateSelection('Data',[array of indexes to be selected]);

4 replies

May 24, 2020 9:38 AM UTC

I think something like:

// -- yourWidget it's the javascript instance of your widget
// -- Where 'Data' it's the name of the infotable property on your widget
// -- [array..] --> if you have single select, something like [3] or multi select [0,3,8]
yourWidget.updateSelection('Data',[array of indexes to be selected]);
seancccAuthor
May 26, 2020 12:51 PM UTC

@CarlesColl ,

 

Thank you for your hint.  While I found updateSelection indeed used to update the Selected Rows,  the widget.runtime.js must also has function "handleSelectionUpdate" defined , otherwise the runtime framework will assume that the widget doesn't care about selection update. 

 

one more question,  where do you get the following API comment ?   I couldn't find it in the ThingWorx Extension Development Guide . 

// -- yourWidget it's the javascript instance of your widget
// -- Where 'Data' it's the name of the infotable property on your widget
// -- [array..] --> if you have single select, something like [3] or multi select [0,3,8]

  

Regards,

Sean

May 26, 2020 12:53 PM UTC

It's my own one 😉