I am trying to update the content of a Sap.m.List control. It keeps holding the same Model, but the binding path for that model changes.
Is there any function which I could use to update my Sap.m.List to display the data inside a new binding path?
I tried using oList.getModel().setPath() and after that a refresh of the model, but this did not change the content of the list.
Thanks in advance for any advice on this!
you need to set the binding context, you can get a new context via the path
var oModel = oList.getBindingContext().getModel();
var oContext = oModel.getContext(sPath);
oList.setBindingContext(oContext);
Change the Element bound to as follows:
var sPath = "<your new path>";
oList.bindElement(sPath);
if you need a handle to your list
var oList = this.getView().byId("<your-list-id>");
Hope this helps.
Related
As a newcomer to javascript and the use of leaflet I'm unsure which subject this should be.
Using the Layer Groups and Layers Control example as a model I wish to assign the Control text to the overlays from a variable.
Inserting the variable name simply uses that as text.
Code I've used follows.
var cities_title_0="cities(N-S)"
var cities_title_1="cities(E-W)"
var overlays = {cities_title_0: cities_layer[0],cities_title_1: cities_layer[1] };
L.control.layers(null,overlays).addTo(map);
How can I get the value of the variable in the control and not it's name please?
Previously (<= ES5) you would have to proceed in 2 steps:
Initialize the object var overlays = {}
Assign your computed key: overlays[cities_title_0] = cities_layer[0]
One way is to put the variable name in [] - eg
var cities_title_0="cities(N-S)"
var cities_title_1="cities(E-W)"
var overlays = {[cities_title_0]: cities_layer[0], [cities_title_1]: cities_layer[1] };
L.control.layers(null,overlays).addTo(map);
I am working with mapbox.js and I am trying to reset a layer that I removed, but stored in a variable. I have created a map object and attached it to a div and stored it as the variable map. I initialize the layers like so
var myLayer = L.mapbox.featureLayer().addTo(map);
var secondLayer = L.mapbox.featureLayer().addTo(map);
Then I store them in a json object
var geoJsons = {"myLayer": myLayer,
"secondLayer": secondLayer
};
in a function below, I have an onclick function which draws on the data attribute of the object clicked to point to the specific layer in the json object.
var layer = $(this).data('layer');
map.removeLayer(geoJsons[layer]);
I then try to re-add it on the click of a different button
geoJsons[layer] = L.mapbox.featureLayer().addTo(map);
This last bit does not work. My question is, is there a way to re-add the layer to the map by calling it from within this json object?
geoJsons[layer] = L.mapbox.featureLayer().addTo(map);
What you are doing here is overwriting the layerobject stored with a new instance of L.mapbox.featureLayer. The stored layer is accessible via geoJsons[layer] (Assuming the layer variable holds the string myLayer or secondLayer) you can add it by simply calling it's addTo method like so:
geoJsons[layer].addTo(map);
//or
map.addLayer(geoJsons[layer]);
i want to show message after binding data but message always shown before binding complete and show the result on the bound table. I want to delay or make callback when binding data is finished.
Thanks for help.
var oModel = new sap.ui.model.odata.ODataModel("sap/opu/odata/sap/*SRV/");
var oSummaryTable = sap.ui.getCore().byId("oSummaryTable");
oSummaryTable.setModel(oModel);
sap.ui.commons.MessageBox.alert("Succeed");
oModel.attachRequestCompleted(function() {
sap.ui.commons.MessageBox.alert("Succeed");
});
How can we set class with mSetting?
For example:
new sap.m.Button({}).addStyleClass("my-class"); //work
Another way?
new sap.m.Button({
styleClass: "my-class" // did'n work
});
Any possibility to set class that way?
As of now (till version SAPUI5 1.28.4), styleClass is not a supported property of sap.m.Button nor its base type's( sap.ui.core.Control) property.
Hence you have to use addStyleClass(sStyleClass) OR in XML view directly.
As #Ivan said, you can use busy property because this exists in the base type sap.ui.core.Control
Hopefully we will this basic functionality in higher releases.
Update: for multiple CSS classes
var oLabel = new sap.m.Label({text:"Sample"}).addStyleClass("sample1 sample2");
OR
var oLabel = new sap.m.Label({text:"Sample"}).addStyleClass("sample1").addStyleClass("sample2");
I have a button into a bar in my XML view:
<Button xmlns="sap.m" id="idMenuBarSoc" text="{flagSocietyBar}" visible="true" icon="sap-icon://filter" press="handlePressSocFilter"/>
in the controller I write (in the init method):
this.getView().setModel('Oracle-Society', 'flagSocietyBar');
but if i test my application the button not show any text... ('')
What should I write in text="{?????????}" ?
That's not going to work... You haven't defined the model type (I think you want to use JSONModel?) and you haven't set the data to the model.
By the look of your code, I think you wanted to define a property 'flagSocietyBar' with value 'Oracle-Society', am I correct?
However, the setModel(oModel, sName) method is used incorrectly here. According to the API, oModel cannot be of type string but should be of type sap.ui.model.Model.
Modify your code to the following:
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({flagSocietyBar : "Oracle-Society"});
this.getView().setModel(oModel);
and your button should then bind to text="{/flagSocietyBar}"
If you need named models, specify it as such:
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({flagSocietyBar : "Oracle-Society"});
sap.ui.getCore().setModel(oModel, "myModel");
and your button should then bind to text="{myModel>/flagSocietyBar}"