on 12-15-2014 9:19 AM
Hi experts,
I have a requirement where i want to validate the country entered by user is exist in sap database or not..if country is not exist it should return an error.
how i can do it?? i'm using odata model.
regards,
Adarsh
Depending on your needs and backend, you could implement a filter when you query your country table, something like: /Country?$filter=Name eq 'Netherlands' and base your logic on the number of results returned.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I assume you perform an odatamodel.read() function?
It has success() and error() callback functions, so -- assuming your error message will be returned as an error through the error callback function -- simply pass its oError.<error_message_location> value to your view
hi maunika,
can you share sample code for it.. i'm trying with odata model but its not working properly..
i have written this piece of code..
var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/Z02_COUNTRY_SRV/", true);
sap.ui.getCore.setModel(oModel) | ||
var deliveryBlockTemplate = new sap.ui.core.ListItem(); | ||
deliveryBlockTemplate.bindProperty("key", "Land1"); | ||
deliveryBlockTemplate.bindProperty("text", "Landx"); |
var myDropDown = oOffDataElem2.addField( new sap.ui.commons.DropdownBox( {});
myDropDown.bindItems({ | ||
path : "/countrySet", | ||
template : deliveryBlockTemplate | ||
}); | ||
myDropDown.setModel(oModel); |
return myDropdown;
Hi adrash,
Please try this
// Create a DropdownBox
var oDropdownBox1 = new sap.ui.commons.DropdownBox("DropdownBox1");
oDropdownBox1.setModel(oModel);
//create a list Item and bind the model to that listitem
var oItemTemplate1 = new sap.ui.core.ListItem();
oItemTemplate1.bindProperty("text", "Customerno");
oDropdownBox1.bindItems("/d/results", oItemTemplate1);
Regards
Moulika
There are quite some things wrong in your code...
I suggest have a good look at SAPUI5 SDK - Demo Kit and it's subchapters, it explains quite well how to implement OData model binding.
If we simply provide you working code, you won't learn anything from it
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.