Skip to Content
0

How to fill a table from an ajax result

Apr 24 at 09:14 AM

32

avatar image
Former Member

Hello,

I am trying to fill a table given the data that I get from an ajax function here is the code and the solution I am trying to apply.

SLOUTION:

I'm trying to set the results to a property in a model that I have defined in manifest (It works the property sets properly) but once I got this I don't know how to get a specified field on the results.

example: "modelDefault>/DetalleStockDuplicadosSet" It has an array with the results. How to acccess to a field "Descripcion" of the array and display on the table?

XML TABLE:

<Table id="tableLlaves" growingScrollToLoad="true" growing="true" items="{path: 'modelDefault>/DetalleStockDuplicadosSet'}">
				     <columns>
				     	<Column width="100px" minScreenWidth="Tablet" demandPopin="true" visible="false"> 
							<header>
								<Label text="Id"/>
							</header>
						</Column>
				      	<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>
						<Column width="100px" minScreenWidth="Tablet" demandPopin="true"> 
							<header>
								<Label text="Incidencia"/>
							</header>
						</Column>
						<Column width="100px" minScreenWidth="Tablet" demandPopin="true"> 
							<header>
								<Label text="Texto de incidencia"/>
							</header>
						</Column>
				     </columns>
				     <items>
                       <ColumnListItem>
                         <cells>
                         	<ObjectIdentifier title="{Id}"/>
                         	<Text text="{path:'Descripcion'}"/>
                         	<CheckBox id="checkID" checked="false"/>
                         	<Select id="sel"/>
                         	<Input id="__input0" ariaLabelledBy="__label8" width="100%"/>
                         </cells>
                       </ColumnListItem>
                    </items>
            	</Table>

SCRIPT:

var selectedId = that.getOwnerComponent().getModel("modelDefault").getProperty("/Id");
var that = this;
$.ajax({
    type: 'GET',
url : "/sap/opu/odata/SAP/ZFIO_LLAVES_STOCK_DPC_SRV/DetalleStockDuplicadosSet?$filter=IId eq '"+selectedId+"'&$format=json",
    dataType: 'json',
    success: function(data,textStatus,jqXHR) {
        var resultados = data.d.results;
        that.getView().getModel("modelDefault").setProperty("/DetalleStockDuplicadosSet", resultados);// resultados[0], false
        that.getView().getModel("modelDefault").setProperty("/EstadosSet", data.d.results);
	console.log(that.getView().getModel("modelDefault").getProperty("/DetalleStockDuplicadosSet"));
    },
    error : function(jqXHR,textStatus,errorThrown) {
	console.log(errorThrown);
	BaseController.getRouter().navTo("ObjectNotFound");
    }
});

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

1 Answer

avatar image
Former Member Apr 25 at 04:35 AM
1

Hi,

Try binding in this format "{modelName>Key}, in your case something like this

<Text text="{modelDefault>Descripcion}"/>

Also remove the id from Checkbox, Select and Input.

regards

GB

Share
10 |10000 characters needed characters left characters exceeded