cancel
Showing results for 
Search instead for 
Did you mean: 

problem bind new data to table sapui5

srahemi
Participant

hi

i cant bind new data to table, I don't know where my problem is.

after click in "filter" button i get new data from odata and convert it to json and set model

but in view i cant see any data

view:

<mvc:View xmlns:html="http://www.w3.org/1999/xhtml" xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns:l="sap.ui.layout" xmlns:f="sap.ui.layout.form" xmlns:smartForm="sap.ui.comp.smartform" xmlns:smartField="sap.ui.comp.smartfield" controllerName="SOPsales_order_approval.controller.View1" displayBlock="true">
	<App>
		<pages>
			<Page>
				<content>
					<Table id="idProductsTable" inset="false"  items="{/E1Set}">
                                                <columns press="tbl_row_click">
							<Column>
								<Text text="موعد تحویل"/>
							</Column>
							<Column>
								<Text text="پیش پرداخت"/>
							</Column>
							<Column>
								<Text text="ی"/>
							</Column>
							<Column>
								<Text text="مبلغ سفارش"/>
							</Column>
							<Column>
								<Text text="نام فروشگاه"/>
							</Column>
						</columns>
						<items>
							<ColumnListItem vAlign="Middle" press="tbl_row_click" type="Active">
								<cells>
									<Text text="{Give_Date}"/>
									<Text text="{Prepayment_Flg_Desc}"/>
									<Text text="{Prepayment_Flg_Desc}"/>
									<Text text="{OrderPrice}"/>
									<Text text="{Shop_Name}"/>
								</cells>
							</ColumnListItem>
						</items>
					</Table>
				</content>
			</Page>
		</pages>
	</App>
</mvc:View>

btn_filter_press: function(oEvent) {
	debugger;
	var that = this;
	var role = this.getView().byId('role').getSelectedItem().getKey();
	var branch = this.getView().byId('branch').getSelectedItem().getKey();
	var state = this.getView().byId('state').getSelectedItem().getKey();

	var Filters_array = {
		values: []
	};
	
	var Filter = new sap.ui.model.Filter({
		path: "role",
		operator: sap.ui.model.FilterOperator.EQ,
		value1: role
	});
	Filters_array["values"].push(Filter);
	
	var Filter2 = new sap.ui.model.Filter({
		path: "branch",
		operator: sap.ui.model.FilterOperator.EQ,
		value1: branch
	});
	Filters_array["values"].push(Filter2);
	
	var Filter3 = new sap.ui.model.Filter({
		path: "state",
		operator: sap.ui.model.FilterOperator.EQ,
		value1: state
	});
	Filters_array["values"].push(Filter3);
	
	
	var reqFilters = new sap.ui.model.Filter({
		filters: Filters_array.values,
		and: true,
	});
	
	this.oDataModel.read("/E1Set",{
		filters: reqFilters.aFilters,
		method: "GET",
		success: function(oResults) {
			var oTable = that.byId("idProductsTable");
			// oTable.unbindItems();
			oTable.setModel(new JSONModel(oResults, true), "E1Set");
		},
		error: function (oError){
			debugger;	
		}
	})
	
},

ori-broda
Explorer

Can you see the data in the table before you use the filter?

Also, I think I had a similar issue and solved it by changing the binding of the table.

Can you show what information oTable contains? (i.e console.log(oTable))

srahemi
Participant
0 Kudos

hi ori_broda

before Filter I don't have any data

oTable:

View Entire Topic
junwu
Active Contributor
success: function(oResults) {
			debugger;	
			var oModel_view = that.getView().getModel("viewModel");
			oModel_view.setProperty("/E1Set",oResults.results);
var oTable = that.getView().byId("idProductsTable"); oTable.setModel(oModel_view, "viewModel"); },
srahemi
Participant
0 Kudos

Hi jun.wu5

Thanks for you response

I try it and still my output didn't change 😞