Hi guys, I'd like to ask how to retrieve and update data from a segment widget using Javascript in Visualizer?

This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal.

These are the 2 specific questions:

How can I access the data of a segment widget that is at the moment using master data?

How can I update the data using Javascript?

Everything is in Visualizer.

Hi,

To read the complete data of the segment you can use

formID.segmentID.data in Free-From project

this.view.segmentID.data in Kony reference architecture

To read specific record data, you can use selectedRowItems, which will return the selected row data.

To update the data you can use setData() which will replace old data with new data. addAll() will keep the old data and append the new data.

To add the data at specific index you can use setDataAt() or addDataAt() methods. Please go through with the doc link for more details.

http://docs.kony.com/konylibrary/visualizer/viz_widget_prog_guide/Default.htm#Segment_Methods.htm%3FTocPath%3DReference%7CSegmentedUI%2520Widget%7CMethods%7C_____0

Hello,

Did my response help you? If yes, make sure you click [Select as Best] under the response to close out the post.

Hi,

For pushing data into a segment dynamically using code, first initialize the widget/elements which you are going to place inside your segment.

For example, if you have a label inside your segment, the initialization code would be like :

frmName.segId.widgetDataMap = { "lblid" : "lblval"};

Then push the values into an array using iteration,if there are more than 1 values

tempArr =[];

for(i=0; i< looplength; i++)

{

var rowData= {"lblval" : "set the value to be passed to the label in segment here"};

tempArr .push(rowData);

}

frmName.segId.setData(tempArr );

I haven't used master data, so don't have an idea on that.

Hope this helps.

--

Thanks