Skip to Content
0
Jun 22, 2015 at 10:11 AM

How to Rebind the data to List

271 Views

Hi all,

Here I am new to sapui5, Please help me.

when i select on single line item list it will show dialog box with some fields, following is screen shot of dialog box.

Now I need to update the storageloc and Quantity fieds remaning field are non editable.

What ever I edit and updated field will be shown in the LinItems List(1st screen shot).

How to bind the updated data to LinItemList ?

Below is the some code



view.js:


<content>

<Panel title="PO Details">

<headerToolbar>

<Toolbar height="3rem">

<Title text="PO Details" />

<ToolbarSpacer />

</Toolbar>

</headerToolbar>

<content>

<ObjectHeader binding="{/POSelectedItem}" title="PO Number"

number="{Ebeln}">

<attributes>

<ObjectAttribute title="Vendor" text="{Lifnr}" />

<ObjectAttribute title="Date" text="{Bedat1}" />

</attributes>

</ObjectHeader>

</content>

</Panel>

<IconTabBar id="idIconTabBarMulti"

class="sapUiResponsiveContentPadding">

<items>

<IconTabFilter icon="sap-icon://notes" text="Line Item Details" width="200px">

<!-- <ObjectHeader title="Line Item Details"></ObjectHeader> -->

<!-- <ScrollContainer height="50%" width="200%" horizontal="false"

vertical="true" focusable="false"> -->

<List items="{/POLineItemList}" growing="true"

growingScrollToLoad="true">

<CustomListItem type="Navigation" press="LineItemDetails">

<HBox>

<Label text="PO Number : "></Label>

<Label text="{Ebeln}"></Label>

</HBox>

<HBox>

<Label text="Quantity :"></Label>

<Label text="{Menge}"></Label>

</HBox>

<HBox>

<Label text="Storage Location :"></Label>

<Label text="{Lgort}"></Label>

</HBox>

</CustomListItem>

</List>

<Button align="center" text="submit" press="submitLineItem"></Button>

</IconTabFilter>

</items>

</IconTabBar>

</content>

</Page>

<Dialog id="editDialoge" title="LineItemDetails">

<content>

<Panel width="auto" class="sapUiResponsiveMargin sapUiNoContentPadding">

<headerToolbar>

<Toolbar>

<Title text="LineItems" level="H2" />

<ToolbarSpacer />

</Toolbar>

</headerToolbar>

<content>

<f:SimpleForm minWidth="2024" maxContainerCols="10"

editable="true" layout="ResponsiveGridLayout" labelSpanL="3"

labelSpanM="3" emptySpanL="4" emptySpanM="4" columnsL="1" columnsM="1" >

<f:content>

<Label text="Item Number" /><Input value="{/lineItemEdit/Ebelp}" enabled="false" />

<Label text="Material No." /><Input value="{/lineItemEdit/Matnr}" enabled="false" />

<Label text="Material Description" /><Input value="{/lineItemEdit/Material}" enabled="false" />

<Label text="Doc Date" /><Input value="{/lineItemEdit/DocDate}" enabled="false" />

<Label text="Plant" /><Input value="{/lineItemEdit/Werks}" enabled="false" />

<Label text="Storage Loc" /><Input value="{/lineItemEdit/Lgort}" />

<Label text="Quantity" /><Input id="quantity" value="{/lineItemEdit/Menge}" /><Label />

<Label text="Item OK" /><CheckBox select="selectCBox"></CheckBox>

</f:content>

<Button text="Save" press="saveLineItem"></Button>

</f:SimpleForm>

</content>

</Panel>

Controller.js

saveLineItem : function() {

var storageLoc = $("#__input5-inner").val();

// console.log(oForm);

var quantity = $("#LineItems_List--quantity-inner")

.val();

console.log(quantity);

if (isCheckBox) {

LineUpdatedData.storageLoc = storageLoc;

LineUpdatedData.quantity =quantity;

oModel.setData(LineUpdatedData);

sap.ui.getCore().setModel(oModel);

console.log(LineUpdatedData);

console.log(oModel.getData());

console.log(globalDataRepo.lineItemEdit.Ebeln);

oModel.getData().globalDataRepo.push({

Ebeln:globalDataRepo.lineItemEdit.Ebeln,

Ebelp:globalDataRepo.lineItemEdit.Ebelp,

Elikz:globalDataRepo.lineItemEdit.Elikz,

Emlif:globalDataRepo.lineItemEdit.Emlif,

Insmk:globalDataRepo.lineItemEdit.Insmk,

Lgort:LineUpdatedData.storageLoc,

Matnr:globalDataRepo.lineItemEdit.Matnr,

Meins:globalDataRepo.lineItemEdit.Meins,

Menge:LineUpdatedData.quantity,

Message:globalDataRepo.lineItemEdit.Message

});

oModel.updateBindings();

globalDataRepo.POLineItemList = oModel.getData();

this.closeDialog();

}

},

selectCBox : function() {

if (isCheckBox) {

isCheckBox = false;

} else {

isCheckBox = true;

}

},

LineItemDetails : function(event) {

// oModel.setData(context);

// app.to("LineItemDetails");

var context = event.getSource().getBindingContext();

console.log(context);

var index = context + "";

index = index.substring(16, 17);

console.log(index);

globalDataRepo.lineItemEdit = globalDataRepo.POLineItemList[index];

console.log(globalDataRepo.lineItemEdit);

globalDataRepo = oModel.getData();

console.log(globalDataRepo);

oModel.setData(globalDataRepo);

sap.ui.getCore().setModel(oModel);

this.getView().byId("editDialoge").open();

},

closeDialog : function() {

this.getView().byId("editDialoge").close();

},

thanks in advance.

Attachments

Rebind Data.png (82.3 kB)
DialogBox.png (106.4 kB)