First Child, Next Sibling - dom

Are the dom core props:
.firstChild
.nextSibling
supported cross-browser-platforrm-browserVersion?

According to QuirksMode, yes, they are supported everywhere.

Related

Is there a way to specify first-day-of-week for Vuetify Date picker globally?

Is there a way to specify first-day-of-week for Vuetify Date picker globally?
I don't want to specify the props on each separately.
No, there isn't a way to do that
You have to use the widget as per documentation (https://vuetifyjs.com/en/components/date-pickers) with the first-day-of-week property.
<v-date-picker
v-model="picker"
:first-day-of-week="1"
></v-date-picker>
if you look into code, you'll notice that the param default is 0, so there's no magical global setting for this.
https://github.com/vuetifyjs/vuetify/blob/master/packages/vuetify/src/components/VDatePicker/VDatePicker.ts#L64
As for few other components' defaults, you can simply wrap it in new component (let's call it MyDatePicker) and use that one across the application instead.
To harness all event handlers intended for Vuetify component VDatePicker upon your custom MyDatePicker, you'll need to add v-on="$listeners".

sap.m.Select: start with a blank selection input element

When using a data aggregation on sap.m.Select, the first entry is always selected. Here's a link to the SDK's preview.
Example code from my app
new sap.m.Select("id-names", {
width: '100%',
}).bindAggregation("items", "data>/trip/names", new sap.ui.core.Item({
text: "{data>Name}"
}));
There is a parameter called selectedKey on the constructor to change this to another index. What I want is the select to be blank, because I want to force my users to make a choice, not blandly accept the first entry in the list.
I could force an blank entry in my aggregation data>/trip/names but that would pollute my list.
Is there a better way to achieve this?
Since the OpenUI5 version 1.34, you can set the forceSelection property to false.
The forceSelection property indicates whether the selection is restricted to one of the items in the list. The default value is true (which means, if the selection is not set, the first item in the dropdown list is selected).
When to set it to false?
If you do not want a default item to be pre selected.
Additional information
https://github.com/SAP/openui5/commit/b2191fd50e2115f8f9d2db7604a75fb50c57591f
Currently, no. There seems to be no better way.
There is a ticket for that on GitHub.
It's also my opinion to avoid messing with the dataset and much liked the idea of adding an additional item aggregate. However my improvement on this is to use a formatter on the control itself so it is clearly visible and executed at the right time.
I make use of a formatter with fully qualified controller to get the control as 'this' parameter. In the formatter function I add a ListItem, as proposed by #Victor S
In XML view
<Select forceSelection="false" selectedKey="{model>/key}" items="{path: 'model>/Items'}" icon="{path: '', formatter: 'mynamespace.Utils.addDeselectOption'}">
In the Utils controller:
addDeselectOption: function() {
var that = this;
this.getBinding("items").attachDataReceived(function(){
that.insertItem(new sap.ui.core.ListItem({text: '', key: undefined}), 0);
});
}
Works form me in UI5 1.52
Even though this solution is not great, I managed to get the empty field stick by adding both, the forceSelection=false property, and also in the controller's onInit function (I used the Select element):
var codeField = this.getView().byId("codeField");
setTimeout(function() {
codeField.insertItem(new sap.ui.core.ListItem({text: '', key: undefined}), 0);
}, 1000);
If the forceSelection=false is left out, the field will load either too early or too late to the drop down, which will cause the wrong selection to be visible. Hope it helps someone.
You can also extend the control and build you own select with e.g. an additional parameter add empty choice...I am actually also thinking about that...

Control property/aggregation updates and re-rendering

If I update a property or aggregation on a control how do I prevent it from rerendering?
For example, if I add a member to an aggregation, I want to render just the new member, not do a full rerender.
Looking for general advice...
You can do it if its a custom control.
In Custom control, provide a new method that add's the delta part and renders it (you can use jQuery).
The new method should also add the aggregation, but should not trigger re-rendering.
Check the add aggregation method definition
addAggregation(sAggregationName, oObject, bSuppressInvalidate?)
the bSuppressInvalidate if true, the control doesn't re-render.
Example:
customControl.prototype.addNewImage(img){
// some code to manipulate dom and add image
//...
//...
this.addAggregation(sAggregationName, img, false)
}
Hope this helps

Creating and setting new models in declarative views

According to the documentation and View's API reference, setting a ResourceModel declaratively in XML or JSON views is possible via resourceBundleName, resourceBundleAlias, etc.
But is there a possibility to declaratively set any other models in these views or controls? If yes, how?
According to the documentation here you can only define one ResourceModel in the declarative way, but you can assign additional models afterwards using:
oView.setModel(oModel, sModelName);
like you would also do with OData/JSON/XML models.
I hope I got your question right, as you have not provided much information.
If you have unified ResourceBundle for a whole project you can attach it in views easily.
var oModel = new sap.ui.model.resource.ResourceModel({
bundleUrl: 'i18n.properties',
locale: sap.ui.getCore().getConfiguration().getLanguage()
});
sap.ui.getCore().setModel(oModel, "i18n");
And then use it from views, e.g.:
<Button text="{i18n>buttonText}" />
Where buttonText is property from ResourceBundle.

dojox.grid.DataGrid hide/disable the header of the grid

I need a option to hide the header from a dojox.grid.DataGrid grid.
Didn't find anything.
I'm grateful for any info!
I use in dojo 1.6 (and probably works since dojo 1.3)
#myGrid .dojoxGridHeader { display:none; }
You can use CSS:
.dojoxGrid-header { display:none; }
This solution is taken from:
http://dojotoolkit.org/reference-guide/dojox/grid/DataGrid.html#hiding-the-headers-of-a-grid
u can connect at the postrender of the data grid. then find the headerGrid element created
then put style display to none.
//workaround the grid calls postrender after
//the component is at the dom.
//so then i can change the style to reset the header to invisible
dojo.connect(grid,"postrender",function(){
var headerGrid =this.domNode.firstElementChild;
headerGrid.style.display="none";
});
I would recommend switching to using the new and improved dgrid instead of datagrid, it is a lot better!
The setting for hiding headers is the attribute 'showHeader' which is a boolean value.
Check out this dgrid tutorial that talks you through defining grid structures including 'showHeader'.