Skip to Content
0

Get element inside a table on controller

May 03 at 03:29 PM

38

avatar image
Former Member

Hello I am trying to get an element on controller function. Easy task right? I am having problems to deal with it.

XML Code:

<Table id="tableLlaves" growingScrollToLoad="true" growing="true" items="{modelDefault>/DetalleStockDuplicadosSet}" headerText="Llaves (*)">
 <columns>
	<Column width="100px" minScreenWidth="Tablet" demandPopin="true"> 
		<header>
			<Label text="Tipo Llave"/>
		</header>
	</Column>
	<Column width="100px" minScreenWidth="Tablet" demandPopin="true"> 
		<header>
			<Label text="Confirmar"/>
		</header>
	</Column>
 </columns>
 <items>
   <ColumnListItem>
	 <cells>
		<Text text="{modelDefault>Descripcion}"/>
		<CheckBox id="checkBox" selected="{modelDefault>Confirmada}" enabled="{path: 'modelDefault>/enabled', formatter: '.checkBox'}" select="onCheck"/>
</cells>
                       </ColumnListItem>
                    </items>
           	</Table>

JS Function:

checkBox: function (oItem) {
	//var o = s.getSource();
	//var t = s.getMetadata().getName();
	
	if(oItem) {
		//var o = oItem.getSource();
		var a = oItem.getBindingContext();
		
		return false;
	}
	
	console.log(oItem);
	return this.getView().getModel("modelDefault").getProperty("/enabled");
},

The method getSource is not working either getBindingContext.

Somebody knows some way to get the checkbox which I do click on?

Thanks.

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

3 Answers

VIPLOVE KHUSHALANI May 04 at 06:50 AM
1

Hey ..

First of all the checkBox is you formatter function which will not give event properties in the parameter so oItem.getSource() and oItem.getBindingContext() don't make sense here ... the parameter of this function will give the path value bind to the property enabled of the check box control ..

If you need the element in the formatter function than you can't get through parameters like you get in the event handler functions .. in this the only way to get the control is through ID of the control ... this.getView().getId("<id of check box control>")..


But why do you want control in the formatter function ??


Thanks

Viplove

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

Thanks VIPLOVE KHUSHALANI,

If it is really the only way then it is too complicated to do a task that should be easy, I think.

How to get the element on the table if the checkbox specified id is "checkBox" but do not make reference to the element that I click on?

I want to apply the formatter function because depending of the data that I get from sap sets it enabled or not.

Example: if selected="{modelDefault>Confirmada}" is true on load the page, then "enabled" should be false.

0

If the requirement is to enable and disable on the basis of check box value ..

than why to use the formatters for that .. Just use expression binding on the enables property like this ..

enabled = "{= ${modelDefault>Confirmada} === false}"

thanks

Viplove

0
Jun Wu May 03 at 05:12 PM
0

what you get ?

oItem.getSource();
Share
10 |10000 characters needed characters left characters exceeded
tisha dharod May 04 at 07:10 AM
0

Hello Diego

Formatter should not be used in case of events . Event functioned name mentioned in XML code is "onCheck" . Please write the below code under onCheck function and it would provide you the value

onCheck: function(oItem)

{ oItem.getParameter("selected") ;

}

Share
10 |10000 characters needed characters left characters exceeded