on 03-13-2015 10:24 AM
Hi,
In my application i need to bind multiple cards to radio button which works fine when i use Radio button group but in addition i need to display one more radio button "New Card" which is static to the same group. This new card is not returned by the oData service. At a time user should be able to select only one radio button either New Card or existing card which is returned by the odata service.
Can someone please help to understand how i can add the New Card to radio button group.
//Create Radio Buttons to for Saved Cards
var oCardRB = new sap.ui.commons.RadioButtonGroup({
id: "CardRBG" ,
tooltip : "Cards",
select : function(){
oController.Card();
}
});
var oItemTemplate1 = new sap.ui.core.Item({id: "CardItem"});
oItemTemplate1.bindProperty("text", {
parts: [
{path: "CardModel>Card_holder_name", type: new sap.ui.model.type.String()},
{path: "CardModel>Card_type", type: new sap.ui.model.type.String()},
{path: "CardModel>Card_Key", type: new sap.ui.model.type.String()},
],
formatter: function(Card_holder_name, Card_type, Card_Key ){
return Card_holder_name + " " + Card_type + " " + Card_Key ;
}
});
oCardRB.bindItems("CardModel>/PaymentCardSet?$filter=UCRN%20eq%20'XXXXXX'", oItemTemplate1 );
oCell1.addContent(oCardRB);
oMatrix3.createRow(oCell1);
If i do like this then aggregation binding stop working. I think i need to add "New Card" as a new entry to the oData model fata so when i bind the radio button, new card come up automatically but don't know how to achieve it. any idea?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Maksim,
I have copied the data into Json model but not able to merge a new entry into this model.
My first question is where to write the code to merge a new entry into model. It should be in Init function or onAfterRendering: function() because different people says different things.
I have a requirement where oData service could return the array when card details stored in the system or if there is no card details it will come back with no data. I need to create a new entry called "New Card" which should be a first radio button of the radio button group.
I have written below code which doesn't work
It returns only array of oData model(3 entry), new entry not added.
var oModel = sap.ui.getCore().byId("CardRBG").getModel("CardModel")
var jsondata = oModel.getData()
jsondata.push({
"UCRN" : "XXXXXXXXXXX",
"BusPartner" : "XXXXXXXXXXX",
"Card_Key" : "New",
"Card_SequenceNumber" : "",
"Card_Issue_Number" : "",
"Card_Start_Date" : "",
"Card_network" : "",
"Card_security_code" : "",
"Card_issuer" : "",
"Card_type" : "",
"Card_expiry_date" : "",
"Card_holder_name" : "New Card",
"Preferred_Card_Indicator" : false,
"Process_Error" : "" });
sap.ui.getCore().byId("CardRBG").setData(jsondata, true);
sap.ui.getCore().byId("CardRBG").bindItems("CardModel>/results", oItemTemplate1);
I would appreciate for any help.
Thanks,
do that code just after you copy data from OData to Json models
var cardRBG = sap.ui.getCore().byId("CardRBG").
var oModel = cardRBG.getModel("CardModel");
var jsondata = oModel.getData();
jsondata.results.push({
"UCRN" : "XXXXXXXXXXX",
"BusPartner" : "XXXXXXXXXXX",
"Card_Key" : "New",
"Card_SequenceNumber" : "",
"Card_Issue_Number" : "",
"Card_Start_Date" : "",
"Card_network" : "",
"Card_security_code" : "",
"Card_issuer" : "",
"Card_type" : "",
"Card_expiry_date" : "",
"Card_holder_name" : "New Card",
"Preferred_Card_Indicator" : false,
"Process_Error" : "" });
oModel.refresh();
cardRBG.bindItems("CardModel>/results", oItemTemplate1);
Hi Swati,
The group has a function to add another item to it.
var myRadio = new sap.ui.core.Item({text:"one", key: "radio1"});
myRadioGroup.addItem(myRadio);
Regards,
Jamie
SAP - RIG
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
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.