sap.viz.ui5.controls.VizFrame.vizSelect() not working as expexted - sapui5

I use the library sap.viz.ui5.controls.VizFrame to create a pie chart. The chart only contains two values, and I need the first to be highlighted. By Highlighted, I mean selected like if the user would have clicked it, to stand out and show the summary.
Using the vizSelection like this does not work:
oVizFrame.vizSelection(
oVizFrame.getModel().getProperty('/myPath/0'),
{clearSelection : true});
I need to appear the graph showing the relevant value highlighted. /myPath is mapped to the vizFrame.
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions : [{
name : 'Object',
value : "{obj}"}],
measures : [{
name : 'Count',
value : '{Count}'} ],
data : {
path : "/myPath"
}
I found this example:
https://sapui5.hana.ondemand.com/#/sample/sap.viz.sample.SelectionByApi/preview
Confusingly it also does not act as I would expect it after the end-point was highligthed.

sap.ui.getCore().byId('Graphics').vizSelection( selection,{clearSelection : true});
you can use this command and it will work:
selection is an array:
data[Value:1, _context_row_number:1]

Related

React Component iterate/loop properties of Mongo object

I do have a Mongo collection that stores albums with predefined "slot" for its images and feel a bit stuck if there a way to loop over the properties of the collection in order to display images in separated divs.
I did used this code for mapping over the album covers and it worked great:
albums() {
return Albums.find().fetch();
}
{this.albums().map( (album) => {
return <div key={album._id}><img src={album.cover} /></div>
})}
But now I ask you to help, is it possible to loop over photoOne, photoTwo, etc... and skip/don't display data if it is empty like in photoThree for example.
{
"_id" : "CHMHbNWWwZGaLGvB6",
"title" : "Text",
"cover" : "link",
"createdAt" : date,
"photoOne" : {
"titleOne" : "Text",
"coverOne" : "link"
}
"photoTwo" : {
"titleTwo" : "Text",
"coverTwo" : "link"
}
"photoThree" : {
"titleThree" : "",
"coverThree" : ""
}
}
I'm not a Mongo user, but in the map function you can check for the existing values, and handle it there. Something like (there is surely a cleaner way, though):
this.albums().map( (album) => {
for (key in album){
if (key.startsWith('photo')){
var title = Object.keys(album[key])[0];
if (album[key][title].length != 0){
console.log("Can use: " + Object.keys(album[key])[0])
}
}
}
})
Results in:
Can Use This: titleOne
Can Use This: titleTwo
Hope that helps, but it seems like having the photos with photoOne, photoTwo you are limiting the number of photos to use and requiring the need to use Object.keys to get the values out (without specifically using album.photoOne, album.photoTwo, etc.
If the album photos were stored in an embedded document, you could just include the photos and titles that existed and avoid having to check for empty ones. You would just loop through the photos that are present....if that makes sense.

SAPUI5 list is not auto-growing

I have a UI5 List which has the following attributes
growing="true"
growingTreshold="50"
growingScrollToLoad="true"
This list is inside a fragment which I include into my view. It used to work pretty well with my old project but unfortunatly since I refactored everything and included SAPUI5 Routing it doesn´t work anymore.
Now if I scroll down it shows me a [More] list item which shows the next 50 entries. Funny about that is, that I get an console error when I click on more stating
Uncaught Error: The segment {id} is required.
I guess this means the inhability of the list to auto-grow is somehow related to my new routing. The components I use look like this
{
pattern : "",
name : navigation.Constants.MyEvents,
view : navigation.Constants.MyEvents,
viewId : navigation.Constants.MyEvents,
targetAggregation : "pages",
targetControl : "idAppControl",
subroutes : [
{
pattern : "{id}",
name : navigation.Constants.EventDetailFragment,
view : navigation.Constants.EventDetailFragment
}
]
}
Does anyone now how to solve this problem? So far I couldn´t find anything related to my problem.
When navigating to the new page in your routing pass in the {id} parameter. i.e
this.getRouter().navTo("yourNewPage", {
from: currentView,
id: passedinHere
}, false);
Not having that is whats tripping up your code.

Meteor - Update Collection with location object (in GeoJSON format)

Here is my schema (simple schema):
officelocation: {
type: String,
label: 'Location of Office',
autoform: {
type: 'map',
afFieldInput: {
type: 'map',
geolocation: true,
searchBox: true,
autolocate: true
}
}
},
location: {
optional: true,
type: 'Point'
}
My server side js code is below (note this is in a collection.after hook) so I want to update it based on the address that user has entered, which I have resolved into lat long:
Providers.update({_id: doc._id}, {$set: {location: {type:"Point", coordinates:[lng,lat]} } });
When I see the file in the collection (db.providers.find();), I see the below.. Note that the location embedded object is empty:
{ "_id" : "X8ZfKYJAP9cduwvmd", "phone" : 999999999, "officelocation" : "40.7192714,14.872363899999982", "createdAt" : ISODate("2015-04-24T02:00:40.447Z"), "updatedAt" : ISODate("2015-04-24T02:00:40.799Z"), "owner" : "GB4TxTHodkykeeXp6", "officeaddress" : "Via Califri, 5, 84099 San Cipriano Picentino SA, Italy", "location" : { } }
I am basically trying to make sure by collections are stored in a geo-spatial-searchable way, but this approach does not seem to work. Any help?
There could be a number of things causing your update to fail, from allow-deny rules to Simple Schema cleaning out your data.
I see that you are using a custom type to store your location. Make sure you have used a Transform to ensure the type isn't lost on the way to the server. From the Simple Schema readme:
Custom object types are treated as blackbox objects by default. However, when using collection2, you must ensure that the custom type is not lost between client and server. This can be done with a transform function that converts the generic Object to the custom object. Without this transformation, client-side inserts and updates might succeed on the client but then fail on the server. Alternatively, if you don't care about losing the custom type, you can explicitly set blackbox: true for a custom object type instead of using a transformation.
Alternatively you could use a sub-schema to define what a location is allowed to look like, instead of using a custom type, but it won't keep the methods of the Point type.

How to update jstree node values without reload

I have a jstree that I created with the following code:
$('#mytree').jstree({"core": { "data" : value
, "themes" : { "dots": false
, "icons": false }
}
}
);
I can rebuild it with new data by this code:
$('#mytree').jstree(true).settings.core.data = new_data;
$('#mytree').jstree(true).refresh();
but it can be expensive when you have a lot of nodes. What I would like to achieve is that I would like update the value of the elements (i.e. the node.text part) without rebuilding the whole tree. I get the new values via websocket in one message (the complete JSON string that will be the new_data) but the structure is not changing. How can I do that? Thank you!
What you need is not refresh() but redraw() thus the code is
$('#mytree').jstree(true).settings.core.data = new_data;
$('#mytree').jstree(true).redraw(true);
You can find the functions in the jstree API.
As per zmirc suggestion, in v3.1 use:
$('#mytree').jstree(true).settings.core.data = new_data;
$('#mytree').jstree(true).refresh();
for deleting the node and reload tree
$('#mytree').jstree(true).refresh();
for those who need to redraw without restart the tree use
jQuery('#data').jstree(true).refresh(true);
worked for me: $('#structureRows').jstree("destroy").empty();
function CreateStructureTree(jsonData)
{
$('#structureRows').jstree("destroy").empty();
$('#structureRows').jstree
({
'core' : {
'data':
[
jsonData,
{
'id' : 'node_2',
'text' : 'Root node with options',
'state' : { 'opened' : true, 'selected' : true },
'children' : [ { 'text' : 'Child 1' }, 'Child 2']
}
]
}
});
}
You can refresh node by this
$('#treeView').jstree(true).refresh_node("node_id_here")
$('#mytree').jstree(true).refresh();
is working, but in my case it causes thread leak.
every refresh adds one more thread
I load data via an url, so my refresh part looks like:
$('#groupTree').jstree(true).settings.core.data.url = get_group_url();
$('#YourJSTREE').jstree("destroy").empty();
Set new data
$('#YourJSTREE').jstree(true).refresh();

Why does Ext.form.ComboBox remove all the values automatically when selected any item in the list?

I've made a combo box and its working fine except when I select one of the items in the combobox, it removes all other values in it. Here is a piece of code:
var comboitemarray = new Array();
for(var comboitems=0;comboitems<listitems.length;comboitems++){
comboitemarray[comboitems] = listitems[comboitems].item;
}
dynamicformfield = new Ext.form.ComboBox({
id: fieldname,
fieldLabel: fieldlabel,
name: fieldname,
editable: false,
autoSelect : true,
store: comboitemarray,
queryMode: 'local',
});
Any idea? Or am I missing anything here?
You gave an Array as store :
store: comboitemarray
Where it expects an Ext.data.Store. Implement an Ext.data.ArrayStore() from that comboitemarray array . Check the documentation of ArrayStore and always test in firebug for the errors.
I behaves that way because it's not a select-box, it's a combo-box.
If you had the following items:
a
aa
aaa
and you selected "aa", there would then be two options in the box: 'aa', and 'aaa'.
If you think carefully about how you'd like it to work, you'll realize that to get what you want will break ability to have any sort of meaningful type-ahead functionality.