on 04-23-2019 7:16 PM
Hello,
I have a sap.m.Table with multiple selection. I'd like to select n checkboxes. Remember this selection and put it into another similar Table by removing the selection out of table 1.
Since I'm a rookie in this area I'd like to ask you for support. I already receive the selected Items via an Event. But I don't know yet how to save them in a right manner into a new model and transfer them to the other table.
Thanks in advance!
Regards!
Andreas
I managed it now with the control type <List>. But after a refresh it's not possible to perform the procedure again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any idea? Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I do not even get an error within the console. But I'm not really sure what to pass here as path:
If I insert the received sPath-> this means its the path from the old model of table 1. If I insert "/data" at least an empty row will appear at table2.
//1st get the selected/scanned items
var oItems = oTable.getSelectedItems();
//var link = oEvent.getSource().getBindingContext();
var oSelectedListItem = oEvent.getParameter("listItem");
var selectedIndex = oTable.indexOfItem(oSelectedListItem);
var oBindingContext = oSelectedListItem.getBindingContext();
var sPath = oBindingContext.getPath();
var oScanModel = new sap.ui.model.json.JSONModel();
oScanModel.setData({
itemArray: [
oItems
]
});
oSTable.setModel(oScanModel);
var oTemplate = new sap.m.ColumnListItem({
cells: [new sap.m.Text({
text: oBindingContext.getProperty("bundle")
})]
});
oSTable.bindAggregation("items", {
// path:sPath,
path: "/itemArray", //sPath,
template: oTemplate
});
oSTable.getModel().updateBindings(true);
oSTable.setSelectedItem([0]);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
3rd:
var oScanModel = new sap.ui.model.json.JSONModel({"data": oItems
});
oSTable.setModel(oScanModel);
var oTemplate = new sap.m.ColumnListItem({cells: [new sap.m.Text({text: oBindingContext.getProperty("bundle") })]});
oSTable.bindAggregation("items", {
path: "/scans",
template: oTemplate
});
oSTable.setSelectedItem([0]);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
2nd try with your approach:
var oTable = this.getView().byId("table");
var oSTable = this.getView().byId("table2");
var msg;
var data = new Array();
var oScanModel = new sap.ui.model.json.JSONModel({'data':data});
oSTable.setModel(oScanModel);
No data there...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Jun!
Thanks for your answer. But I'm afraid I need here further help. My current coding looks like that:
var oTable = this.getView().byId("table");
var msg;
//1st get the selected/scanned items
var oItems = oTable.getSelectedItems();
//2nd create a new model
var oScanModel = new sap.ui.model.json.JSONModel();
var oSTable = this.getView().byId("table2");
for (var i = 0; i < oItems.length; i++) {
var oSTemplate[i] = new sap.m.ColumnListItem({
cells: [new sap.m.Text({
text: oItems[i].getCells()[0].getText()
})]
}),
/* msg = oItems[i].getCells()[0].getText();
MessageToast.show(msg);*/
}
oSTable.bindAggregation("items", {
path: "/",
template: oSTemplate
});
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
var data=[];
data.concat(/*yourselecteditemarray*/)
var model=new Jsonmodel({'data':data});
bind the model to your new table
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.