cancel
Showing results for 
Search instead for 
Did you mean: 

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

dirk_wieczorek
Participant
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member182862
Active Contributor
0 Kudos

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

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

dirk_wieczorek
Participant
0 Kudos

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

former_member182862
Active Contributor
0 Kudos

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

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

junwu
Active Contributor
0 Kudos

why you want to know?

dirk_wieczorek
Participant
0 Kudos

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

junwu
Active Contributor
0 Kudos

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

Sharathmg
Active Contributor
0 Kudos

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

dirk_wieczorek
Participant
0 Kudos

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

junwu
Active Contributor
0 Kudos

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

Sharathmg
Active Contributor
0 Kudos

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