on 05-22-2013 10:51 AM
...
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({
appTypes:[{skey:"P", stext:"岗位代理 "},
{skey:"R", stext:"角色代理 "}],
reasomTypes:[{skey:"A", stext:"公出 "},
{skey:"B", stext:"出差 "},
{skey:"C", stext:"请假 "},
{skey:"D", stext:"其它 "} ],
editable: true,
selectedIndex: 0
});
sap.ui.getCore().setModel(oModel,"myList");
//*********************************
// RadioButtonGroup
function LBSelect(oEvent){
var iIndex = oEvent.getParameter("selectedIndex");
oModel.setProperty("selectedIndex", iIndex);
};
var oRBGroup1 = new sap.ui.commons.RadioButtonGroup("RBGEntry1");
//oRBGroup1.setModel(oModel);
oRBGroup1.bindProperty("editable", "myList>/editable");
oRBGroup1.bindProperty("selectedIndex", "myList>/selectedIndex");
oRBGroup1.attachSelect(LBSelect);
var oItemTemplate1 = new sap.ui.core.Item();
oItemTemplate1.bindProperty("key", "skey");
oItemTemplate1.bindProperty("text", "stext");
//oItemTemplate1.bindProperty("enabled", "enabled");
oRBGroup1.bindItems("myList>/appTypes", oItemTemplate1);
oMatrix.createRow("代理类别", oRBGroup1,null);
//oPanel.addButton(b1);
oPanel.addContent(oMatrix);
...
data bind failed, Anybody help me ?
Thanks
Thanks, but not work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found this from the SAP demokit:
Hi Shen,
I've played a litle with your example and tried to use two separate models to create two separate RadioButtonGroups. For me this is working fine. But this might be due to the fact that I'm using the most current SAPUI5 version... . Please find the results of my "experiments" attached as index.html. I hope the necessary SAPUI5 version will be available on your side soon.
Kind Regards, Frank
var oModelappAlias = new sap.ui.model.json.JSONModel();
oModelappAlias.setData({
appTypes : [ {
skey : "P",
stext : "Text for 'P' " // orig: "岗位代理"
}, {
skey : "R",
stext : "Text for 'R''" // orig: "角色代理"
} ],
editable : true,
selectedIndex : 0
});
sap.ui.getCore().setModel(oModelappAlias,"appAlias");
//*********************************
// RadioButtonGroup 1
function LBSelect(oEvent){
var iIndex = oEvent.getParameter("selectedIndex");
oModel.setProperty("selectedIndex", iIndex);
};
var oRBGroup1 = new sap.ui.commons.RadioButtonGroup("RBGEntry1");
oRBGroup1.bindProperty("editable", "appAlias>/editable");
oRBGroup1.bindProperty("selectedIndex", "appAlias>/selectedIndex");
oRBGroup1.attachSelect(LBSelect);
var oItemTemplate1 = new sap.ui.core.Item();
oItemTemplate1.bindProperty("key", "appAlias>skey");
oItemTemplate1.bindProperty("text", "appAlias>stext");
oRBGroup1.bindItems("appAlias>/appTypes", oItemTemplate1);
//*********************************
// RadioButtonGroup 2
var oModelreasomAlias = new sap.ui.model.json.JSONModel();
oModelreasomAlias.setData({
reasomTypes : [ {
skey : "A",
stext : "Text for 'A'" // orig: "公出 "
}, {
skey : "B",
stext : "Text for 'B'" // orig: "出差 "
}, {
skey : "C",
stext : "Text for 'C'" // orig: "请假 "
}, {
skey : "D",
stext : "Text for 'D'" // orig: "其它 "
} ],
editable : true,
selectedIndex : 0
});
sap.ui.getCore().setModel(oModelreasomAlias,"reasomAlias");
var oRBGroup2 = new sap.ui.commons.RadioButtonGroup("RBGEntry2");
oRBGroup2.bindProperty("editable", "reasomAlias>/editable");
var oItemTemplate2= new sap.ui.core.Item();
oItemTemplate2.bindProperty("key", "reasomAlias>skey");
oItemTemplate2.bindProperty("text", "reasomAlias>stext");
oRBGroup2.bindItems("reasomAlias>/reasomTypes", oItemTemplate2);
oMatrix = new sap.ui.commons.layout.MatrixLayout();
oMatrix.createRow("Text in Martix Row", oRBGroup1,oRBGroup2); // orig: "代理类别"
oMatrix.placeAt("content");
Hi Frank,
Is Multimodelling possible only with JSON model, I tried using it OData but didn't get.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Priya,
Multimodel Support (see here OpenUI5 SDK - Demo Kit for details) is avaliable for all model types.
Regards, Frank
Hi Shen,
when you use a model alias like you do with:
sap.ui.getCore().setModel(oModel,"myList");
you need to use this alias "at all places" in the data binding too, e.g.
oItemTemplate1.bindProperty("key", "myList>skey");
Regards, Frank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Still not work for multiple model.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({
appTypes:[{skey:"P", stext:"岗位代理 "},
{skey:"R", stext:"角色代理 "}],
reasomTypes:[{skey:"A", stext:"公出 "},
{skey:"B", stext:"出差 "},
{skey:"C", stext:"请假 "},
{skey:"D", stext:"其它 "} ],
editable: true,
selectedIndex: 0
});
sap.ui.getCore().setModel(oModel,"myList");
//*********************************
// RadioButtonGroup
function LBSelect(oEvent){
var iIndex = oEvent.getParameter("selectedIndex");
oModel.setProperty("selectedIndex", iIndex);
};
var oRBGroup1 = new sap.ui.commons.RadioButtonGroup("RBGEntry1");
//oRBGroup1.setModel(oModel);
oRBGroup1.bindProperty("editable", "/editable");
oRBGroup1.bindProperty("selectedIndex", "/selectedIndex");
oRBGroup1.attachSelect(LBSelect);
var oItemTemplate1 = new sap.ui.core.Item();
oItemTemplate1.bindProperty("key", "skey");
oItemTemplate1.bindProperty("text", "stext");
//oItemTemplate1.bindProperty("enabled", "enabled");
oRBGroup1.bindItems("/appTypes", oItemTemplate1);
oMatrix.createRow("代理类别", oRBGroup1,null);
//oPanel.addButton(b1);
oPanel.addContent(oMatrix);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.