Skip to Content
0

Determine index of line sap.m.table where something was changed

Aug 02, 2017 at 04:38 PM

92

avatar image

Hello,

i have an sap.m.table wiht

C1 C2 C3 C4 c5

Text text Radiobuttongroup Text
..

..

Text text Radiobuttongroup Text.

When a radiobutton is selected the onSelect Event is triggerd.

Is there an easy way to get the Index of the line in the table where the button was selected?

At this moment i use oEvent.getId() and split it so that i get the index number from there.
Is there an easier way to accomplish that?

Regards

Dirk

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Jun Wu Aug 02, 2017 at 06:07 PM
0

why you want to know?

Show 5 Share
10 |10000 characters needed characters left characters exceeded

I need to trigger some changes in the line in which the rb was pushed depending on if yes or no was pushed. I am certain there are better ways to do this but i am new in this thema and lack some experience.

Regards

Dirk

0

don't use index, usually it is not needed and is not a good idea.

0

Dirk,

How is the data mapped to the table? Do you a single model and its elements mapped to the properties of the column?

If its a single model, then its much easier to get the entry of the model which is being set.

Regards,

Sharath

0

its a single Json Model which is bound to a sap.m.table.

The user interacts with it through setting the radiobuttons.

The problem is the event i get has is source the RB not the table.
The RB is part of the table.
So how do i get to the entry?

Any advice welcome.

Regards

Dirk

0

RB.getBindingContext("YOURMODELNAMESKIPIFYOUDON'THAVE").getObject() will give you the record which is bind to that row

0
Sharath M G Aug 02, 2017 at 05:47 PM
0

Check with the mProperties method of the onSelect event of the radio button group. If you can get the selected item, that should give you the index of the row.

Regards,

Sharath

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member
Aug 03, 2017 at 03:35 AM
0

there are many ways. One way is to use binding path

http://jsbin.com/pulenom/edit?js,output

Show 2 Share
10 |10000 characters needed characters left characters exceeded

I tried that. My View code is as follows.

items="{Target_Group_Model>/}" >

<columns>

<Column> <header> <Text text= "Customer" /></header> </Column>
<Column> <header> <Text text= "Contact Person" /> </header> </Column>
<Column> <header> <Text text= "Yes No" /> </header> </Column>
<Column> <header> <Text text= "Reason" /> </header> </Column>
</columns> <ColumnListItem>
<Text text="{Target_Group_Model>CompanyName}" /> <Text text="{Target_Group_Model>NameLast}" />
<RadioButtonGroup id="DeleteGroupFlag" columns="2">
<buttons>
<RadioButton id="DeleteYes" select="onReceiverTypeSelect"
selected="{path:'Target_Group_Model>Yes', formatter:'.Formatter.getBoolean'}">
<customData> <core:CustomData key="Delete" value="Y"/> </customData>
</RadioButton> <RadioButton id="DeleteNo" select="onReceiverTypeSelect"
selected="{path:'Target_Group_Model>No', formatter:'.Formatter.getBoolean'}">
<customData> <core:CustomData key="Delete" value="N"/> </customData>
</RadioButton> </buttons> </RadioButtonGroup>
</ColumnListItem> </Table> </content>

Your solution doesn't work on this code . When i call bindingcontext in the event i get undefined.

Any advice?

Regards

Dirk

0
Former Member
Dirk Wieczorek

Since you are binding to Target_Group_Model then you have to do this

var oContext = oEvent.getSource().getBindingContext('Target_Group_Model');

0