Skip to Content
avatar image
Former Member

Get element inside a table on controller

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • May 04 at 06:50 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • May 03 at 05:12 PM

    what you get ?

    oItem.getSource();
    Add comment
    10|10000 characters needed characters exceeded

  • May 04 at 07:10 AM

    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") ;

    }

    Add comment
    10|10000 characters needed characters exceeded