on 01-21-2015 3:24 PM
Hi experts,
playing around with table and popups.
What I haave at the moment:
a table (sap.ui.table.Table), binded to a gateway service (oTable.bindRows("/HeaderSet"), with a ODataModel (sap.ui.getCore().byId("Header").setModel(oModel);)
Now I have added a column to this table where I can enter some data (in my case quantity).
Top of the table,I have a button "Save", which opens a new view in a popup (sap.ui.ux3.OverlayDialog).
This Popup also includes a table.
What I want - show in this new view all data from view1, where something is entered in my column.
The data is not in SAP, something internal, I just want to show these lines where I have entered a quantity.
How to do this?
Thanks
Michael
Is that new column input field for qty bound to the model?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
var itemsModel = {};
Object.defineProperty(itemsModel, "ChangedItems", {
get: function () {
return $.map(
$.grep(
oTable.getBinding("rows").getContexts(),
function( context, i ) {
if (context.getObject().<NAME OF QTY PROPERTY >) {
return true;
}
return false;
}),
function(context, j) {
return context.getObject();
});
}
});
var jModel = new sap.ui.model.json.JSONModel(itemsModel);
sap.ui.getCore().setModel(jModel, "ChangedItemsModel");
In a popup set model to table and bind a table rows to "ChangedItemsModel>/ChangedItems" CdsfgdshangedItemsModel
Wow, alsmost done...have added your coding, everythings working, but my field is always empty.
How I defined the textfield:
var oQty = new sap.ui.commons.TextField({
}
).bindProperty("value","menge", function(cellValue){
$('#' + this.getId()).css("background-color","yellow");
return cellValue;
});
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
id : "menge",
text : "TEST"
}),
template: oQty,
width : "10%",
}));
I think something is missing here?
view1:
var oTable = new sap.ui.table.Table({
id : "oTable",
height : "100%",
visibleRowCountMode : sap.ui.table.VisibleRowCountMode.Auto,
editable : false,
//NavigationMode: sap.ui.table.NavigationMode.Scrollbar,
//selectionMode : sap.ui.table.SelectionMode.None,
}
});
oController.addCol(oTable, "Kontrakt", "konnr", "30%");
(.....)
var oQty = new sap.ui.commons.TextField({
}
).bindProperty("value","menge", function(cellValue){
$('#' + this.getId()).css("background-color","yellow");
return cellValue;
});
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
id : "menge",
text : "Conf."
}),
template: oQty,
width : "15%",
}));
(........)
oTable.bindRows("/HeaderSet");
Then comes your part (with the itemsModel, JSON model)
Popup code:
var oTable = new sap.ui.table.Table({
height : "100%",
visibleRowCountMode : sap.ui.table.VisibleRowCountMode.Auto,
editable : false,
//NavigationMode: sap.ui.table.NavigationMode.Scrollbar,
//selectionMode : sap.ui.table.SelectionMode.None,
}
});
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({
text: "Beleg"}),
template: new sap.ui.commons.TextView({
text: "{ChangedItemsModel>/ChangedItems>ebeln}"})
}));
oTable.bindRows("ChangedItemsModel>/ChangedItems");
and may be add but not sure it is 100% needed
http://jsbin.com/yevanebaqe/2/edit
See - I have added a colum where I can enter the quantity...depending on this, the second table should be updated.
That's exactly my problem - when I use a binded field, the coding will check the binding value (menge_conf), not the vlaue I have entered here.
Hi,
sorry for my late reply, was on different business trips last week(s).
Okay, what I have done now - copied the whole code to a new eclipse project to see if it's working.
Fine, doing what I want.
Now I only replaced the model by my oData part:
odataUrl = "/sap/opu/odata/sap/ZWWW_TESTONLY/";
var odataUser = "remoteuser";
var odataPass = "remotepass";
var oModel = new sap.ui.model.odata.ODataModel(odataUrl, false, odataUser, odataPass);
sap.ui.getCore().setModel(oModel);
And now it's not working anymore - its showing the data as expected in first view on top, when I enter some data in the confirmed qty field nothing is happening...
Damn"!
Hi Micheal,
As Kai Helferich said you could loop through the table in view1 and populate the same into a empty JSON model and then bind this model to the table in view2.
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In this case, I would generate new data, by looping the data of the model from view1 and select only those rows which you mentioned. Then set this new data to the model of view2/dialog.
Maybe there is a better way.
EDIT: To the community: Something like XPATH would be nice for oData Path. Or is there already a functionality like that?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.