How to set width of a control inside a function for QUnit test? - sapui5

I have a scrollContainer which I need to set the width of. However, i'm not sure how to access the width inside my test file.
I can access the controller through
this.oViewStub = new Control()
var oScrollContainer = new sap.m.ScrollContainer()
this.oViewStub.byId returns oScrollContainer <-- pseudocode
This is the code i'm trying to reach in my test file:
this.getView().byId("scrollContainer").$().parent().parent().width().
So I have this.getView().byId("scrollContainer") covered as it returns oScrollContainer but i'm unable to set/get the width of it. How do I fix this?

1) Create a CSS file and define a class with the width that you want;
2) this.getView().byId("scrollContainer").addStyleClass("yourClass");
3) If it still doesn't work, probably the SAPUI5 standard code is overwriting your CSS. In this case you can specify a more precise path to reach your scroll container in the CSS file, but one thing that should work is to include the property !important when you set the with in your CSS file:
.yourClass {
width: 7rem !important;
}

something like sinon.stub($.prototype, 'width').returns(900) will work

Related

How to zoom a GtkTreeView

I want to zoom a GtkTreeView. Initially I thought I simply could use transform to do that, but it seems like GTK CSS currently does not support transform.
So reading up on the CSS docs, it seems my only chance would be to set font-size.
Now naively I tried to set font-size to 200% in GtkStyleContext.
All I get then is
g_object_set_is_valid_property: object class 'GtkStyleContext' has no property named 'font-size'
So how is one supposed to set font-size in code?
You can start with this:
css_provider = Gtk.CssProvider()
css = b"""treeview.view {font-size: 200%;}"""
css_provider.load_from_data(css)
style_context.add_provider_for_screen(screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
But, this will set 200% to all treeviews.
If you want (and you probably do) a custom style class which you can attach to any widget, it should look something like
.my_style_class { font-size: 200%; }
And you add this class to specific widget's StyleContext:
widget.get_style_context().add_class("my_style_class")

Is there way to set detailRowHeight prop to 100% in ag-grid?

Recently started working on a master detail structure angular ag-grid. The structure has two levels of master-detail nesting. I need to fix the heights of inner - 2 grids such that they occupy all available real estate on the screen. Currently, ag-grid defaults it to 300 px and a lot of whitespace or unused space appears on a 1920x1200 screen resolution monitor. I also need to have fixed headers for all grids.
Any ideas or pointers would be appreciated...
Update: Referring to a forked version of plunker example from ag-grid here - https://next.plnkr.co/edit/yUzo4EqONEmgCmIw This is simple and basic set up for master-detail grid.
Note that: I haven't set any detail row height and have setup just one record to show up in the grid to test for the issue.
If you run the plunker code and view the result in separate window, notice that the inner / child grid doesn't occupy all the space available below it. In other words, it doesn't take as much as space/height available from parent container (master's detail row). The default 300px master detailRowHeight is making height fixed for inner grid. Also, from documentation, detailRowHeight prop doesn't seem to take something similar as 100% or 100vh and only takes fixed pixels number. Added a picture of the example below and the height / unused space I referred
We have different resolutions that users use to view data in grid and the heights of inner grids need to auto-adjust taking max. available space to show most information in the grids.
You could try something like this, I pulled it from the documentation:
In your component.ts file add this method. If it's a detail row it will apply different calculations than the other rows.
public rowHeight(params) {
if (params.node && params.node.detail) {
var offset = 80;
var allDetailRowHeight = params.data.callRecords.length * 28;
return allDetailRowHeight + offset;
} else {
// otherwise return fixed master row height
return 25;
}
};
In your template add the following: [getRowHeight]="rowHeight"
<ag-grid-angular
#agGrid
style="width: 100%; height: 100%;"
id="myGrid"
class="ag-theme-balham"
[columnDefs]="columnDefs"
[masterDetail]="true"
[detailCellRendererParams]="detailCellRendererParams"
[getRowHeight]="rowHeight"
[rowData]="rowData"
(gridReady)="onGridReady($event)"
></ag-grid-angular>
Hopefully this will get you moving forward. Good Luck!
https://www.ag-grid.com/javascript-grid-master-detail/#detail-row-height
So I don't have a great, full solution for you but as a starting point I would use CSS to override the styles ag-grid is setting - I don't think detailRowHeight is going to help.
Here's my plunk getting close to what you want with some simple CSS I put in index.html. You can use !important to override ag-grid styles, or you could use javascript to set the CSS after ag-grid does. I prefer !important in this case and don't have to worry about timing.
https://next.plnkr.co/edit/mmXBBJE5Wa1JrX7v
The problem I wasn't going to get into is getting it to dynamically fill up available space, depending on the row selected, scroll position, etc. I can't think of any simple way to achieve that - I do this type of thing in grid often and end up writing javascript to calculate the available space, and then set the CSS in javascript.
In ag-grid you have the possibility to set auto height for details.
Set grid property detailRowAutoHeight=true to have the detail grid to dynamically change it's height to fit it's rows.
const gridOptions = {
// dynamically set row height for all detail grids
detailRowAutoHeight: true,
// other grid options ...
}
However if you are providing your own detail component...
detailCellRenderer: 'MyOwnDetailsComponent',
then, it might not work and you will still need to provide an grid options height detail content through...
detailRowHeight: 560,
Please see the ag-grid documentation here

Is it possible to change the font-size of the values within an ion-picker?

I made an ion-picker with which I can configure the font-size on my Ionic-App. So now I would like to change the font-size within the picker so that the user can see how big the font will be, before he has to confirm it. So for example if you scroll down and select 150%, it should re-scale the font-size to 150% just within the ion-picker.
I already know how to read the current value without confirming it and how to change the font in the entire app, so the only thing that's left would be to change the font of the picker-values.
add global.scss
.picker-opt{
font-size: 12px; //change size depend your Requirement
}
Yeah.
All what you need is to give the item an id;
And you make normal javascriptcode which is var elementsize = getelementbyid('and put there the item id);
Then
Elementsize.style["font-size"] = thepicker.value;
And that will solve your problem.
Or in otherway it can be binded with variable and ngmodule with this variable .
Regards.

React-dnd - change styling of dropTargets on dragStart

I got a app that shows multiple pages, which are dragable. As the content of those can get very long I want to show only the page-name and limit the height of the page to about 50px on beginDrag() and reset the height to auto on endDrag(). Unfortunately this doesnt work, the styles get just ignored. I think this happends because react-dnd needs to keep the proportion of the elements so it can handle the drop-targets and knows which component is at which position. Is there any other way to accomplish this?
If you use a dragPreview then it will use that instead of the screenshot-ed component, similar to what he does in the tutorial (http://gaearon.github.io/react-dnd/docs-tutorial.html):
componentDidMount: function () {
var connectDragPreview = this.props.connectDragPreview;
var myPlaceholder = <Placeholder /> // A fake component with the height you want
myPlaceholder.onload = function() {
connectDragPreview(myPlaceholder);
}
}
(Note that you'll have to inject the connectDragPreview through the collector like he did as well)
I'm not quite sure I understand the problem but may be connectDragPreview can help you?
Some useful info here

Twitter Bootstrap - Dropdown height too small

I am using bootstrap in an Ruby on Rails app. I use Firefox. I find that the height of the dropdown field (select tag) is too small.However the height of the text fields are appropriate. I had too add the below code to application.css to fix it:
select {
height: 38px !important;
}
Now dropdown shows its content properly though its overall height (box) is a bit bigger that text fields. Is there a neater way to fix the issue?
I found it more appropriate to remove styling from application.scss and modify the app/assets/stylesheets/custom.css.scss instead. custom.css.scss is generated by Bootstrap. The padding for all FORM elements was set to 10px in that file. I set padding for SELECT element to 2px and left the rest intact.