cancel
Showing results for 
Search instead for 
Did you mean: 

How to push existing specific rows to the top of the table in sapui5?

Ranjith
Participant
0 Kudos

I have a table with some 100 rows. if the value of a data is greater than 7, i have to show such rows at the top of the table. how to do it in sapui5 using js or jquery.

vedaradhya
Participant
0 Kudos

which table you'r using sap.m.Table or sap.ui.table.Table. ?

you can pass sorter on binding data

Ranjith
Participant
0 Kudos

I am using sap.m.table.

Accepted Solutions (1)

Accepted Solutions (1)

vedaradhya
Participant

Hi,

pass the sorter in binding

items="{path:'ENTITYSET PATH', sorter: { path: 'PROPERTY NAME', descending: true}}"

Here is the code sample

myview.xml

<Table  items="{path:'data>/ProductCollection', sorter: { path: 'Price', descending: true}}">
						<columns>
							<Column width="12em"><Text text="Product"/></Column>
							<Column><Text text="Supplier"/></Column>
							<Column id="netPrice" hAlign="End"><Text text="Price"/></Column>
						</columns>
						<items>
							<ColumnListItem>
								<cells>
									<Text text="{data>Name}" />
									<Text text="{data>SupplierName}"/>
									<ObjectNumber number="{path: 'data>Price'}"/>
								</cells>
							</ColumnListItem>
						</items>
</Table>

mycontroller.js

	onInit: function() {
		var oJsonModel = new sap.ui.model.json.JSONModel({
				"ProductCollection": [{
					"ProductId": "HT-1000",
					"Name": "Notebook Basic 15",
					"SupplierName": "Very Best Screens",
					"Price": 5
				}, {
					"ProductId": "HT-1001",
					"SupplierName": "Very Best Screens",
					"Name": "Notebook Basic 17",
					"Price": 2
				}, {
					"ProductId": "HT-1002",
					"SupplierName": "Very Best Screens",
					"Name": "Notebook Basic 18",
					"Price": 8
				}, {
					"ProductId": "HT-1003",
					"SupplierName": "Smartcards",
					"Name": "Notebook Basic 19",
					"Price": 7
				}, {
					"ProductId": "HT-1007",
					"SupplierName": "Technocom",
					"Name": "ITelO Vault",
					"Price": 7
				}]
			}); 
	 this.getView().setModel(oJsonModel, "data");
	}

Answers (0)