Align button horizontally in top of frame and table bottom vertically - scala

I get in trouble with the fact of after clicking on a button : I would like my table is set at bottom of my button but it's not that
I've managed to get it without after clicking a button but without, I've tested many things and nothing.
Here is the code :
contents = new BoxPanel(Orientation.Horizontal) {
contents += Button("Top 10 most commun runways latitude") {
val headers = Array.tabulate(10) {"Col-" + _}.toSeq
val rowData = Array.tabulate[Any](10, 10) {"" + _ + ":" + _}
contents += new ScrollPane(new Table(rowData, headers))
}
contents += Button("10 highest and lowest number of countries") {
}
contents += Button("Type of runways per country") {}
}
What I get
What I would like

Related

How to properly display floating Buttons on top of BottomNavigationView?

I want to display 2 "floating buttons" a bit on top of a BottomNavigationView if one of its menu is clicked.
Here's my attempt. Basically it uses an AlertDialog supplied with a LinearLayout (full code: https://github.com/anta40/ButtonAnimTest)
bottomNav.setOnItemSelectedListener { menu ->
when (menu.itemId){
R.id.game_menu -> {
val dialogBuilder = AlertDialog.Builder(this)
val customView = layoutInflater.inflate(R.layout.custom_alert_layout, null)
dialogBuilder.setView(customView)
dialogBuilder.setCancelable(true)
val btnYes = customView.findViewById<Button>(R.id.btn_dialog_yes)
val btnNo = customView.findViewById<Button>(R.id.btn_dialog_no)
/*
taken from https://stackoverflow.com/questions/9467026/changing-position-of-the-dialog-on-screen-android
*/
val alert = dialogBuilder.create()
val dialogWindow = alert.window
val layoutParams = dialogWindow!!.attributes
layoutParams.gravity = Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL
layoutParams.flags = layoutParams.flags and WindowManager.LayoutParams.FLAG_DIM_BEHIND.inv()
dialogWindow.attributes = layoutParams
dialogWindow.setBackgroundDrawable(ColorDrawable(android.graphics.Color.TRANSPARENT))
btnYes.setOnClickListener {
alert.dismiss()
}
btnNo.setOnClickListener {
alert.dismiss()
}
alert.show()
true
}
}
false
}
}
There are 2 problems:
The LinearLayout is displayed too high, aligned with the TitleBar. What I want is just a little bit on top of the BottomNavigationView, like 10dp or 20dp.
The screen is dimmed a bit. I don't want the brightness to be changed when those buttons appear.
How to fix these?

ScalaFX: how to wrap text in a TableCell

I want to show a list of key and values in a TreeTableView, and some of the values are a bit longer text which I want to wrap around and show completely.
I thought I use TextFieldTreeTableCell with wrapText and vgrow as follows:
val valCol = new TreeTableColumn[(String,String), String] {
text = "Header"
cellValueFactory = { p => StringProperty(p.value.value.value._2) }
cellFactory = { p => new TextFieldTreeTableCell[(String,String),String]() {
wrapText = true
vgrow = Priority.Always
} }
}
But the text is only shown in one line wiht ... at the end.
What am I missing?

ChartJS: Custom tooltip always displaying

Im using ChartJS to create a graph on my website.
Im trying to create a custom tooltip. According to the documentation, this should be easy:
var myPieChart = new Chart(ctx, {
type: 'pie',
data: data,
options: {
tooltips: {
custom: function(tooltip) {
// tooltip will be false if tooltip is not visible or should be hidden
if (!tooltip) {
return;
}
}
}
}
});
My problem is that the tooptip is never false and because of this my custom tooltip is always displayed.
Please see this JSFiddle (line 42 is never executed)
Question: Is it a bug that tooltip is never false, or am I missing something?
The custom tooltip option is used for when you want to create/style your own tooltip using HTLM/CSS outside of the scope of the canvas (and not use the built in tooltips at all).
In order to do this, you must define a place outside of your canvas to contain your tooltip (e.g. a div) and then use that container within your tooltips.custom function.
Here is an example where I used a custom tooltip to display the hovered pie chart section percentage in the middle of the chart. In this example I'm generating my tooltip inside a div with id "chartjs-tooltip". Notice how I interact with this div in my tooltips.custom function to position and change the value.
Also, the correct way to check if the tooltip should be hidden is to check it's opacity. The tooltip object will always exist, but when it should not be visible, the opacity is set to 0.
Chart.defaults.global.tooltips.custom = function(tooltip) {
// Tooltip Element
var tooltipEl = document.getElementById('chartjs-tooltip');
// Hide if no tooltip
if (tooltip.opacity === 0) {
tooltipEl.style.opacity = 0;
return;
}
// Set Text
if (tooltip.body) {
var total = 0;
// get the value of the datapoint
var value = this._data.datasets[tooltip.dataPoints[0].datasetIndex].data[tooltip.dataPoints[0].index].toLocaleString();
// calculate value of all datapoints
this._data.datasets[tooltip.dataPoints[0].datasetIndex].data.forEach(function(e) {
total += e;
});
// calculate percentage and set tooltip value
tooltipEl.innerHTML = '<h1>' + (value / total * 100) + '%</h1>';
}
// calculate position of tooltip
var centerX = (this._chartInstance.chartArea.left + this._chartInstance.chartArea.right) / 2;
var centerY = ((this._chartInstance.chartArea.top + this._chartInstance.chartArea.bottom) / 2);
// Display, position, and set styles for font
tooltipEl.style.opacity = 1;
tooltipEl.style.left = centerX + 'px';
tooltipEl.style.top = centerY + 'px';
tooltipEl.style.fontFamily = tooltip._fontFamily;
tooltipEl.style.fontSize = tooltip.fontSize;
tooltipEl.style.fontStyle = tooltip._fontStyle;
tooltipEl.style.padding = tooltip.yPadding + 'px ' + tooltip.xPadding + 'px';
};
Here is the full codepen example.
I hope that helps clear things up!

Scroll down in Ui5 List using growing feature

I want to Scroll down in my Ui5 List automaticly when new Items are added to my JSON-Model.In my List growing and growingScrollToLoad are set "true".
To scroll down automatically I implemented something like this:
setTimeout(function() {
var Scrolldown = sap.ui.getCore().byId("MasterItem");
var ul = Scrolldown.$().find('ul');
var ul_id = ul.attr('id');
ul.find('li:nth-child(' + (rowCount - 1) + ')').focus();
ul.find('li:nth-child(' + (rowCount - 1) + ')').blur();
});
But since I've activated growing this doesn't work anymore.
Do you have any suggestions ?

Dynamically Generated Telerik MVC3 Grid - Add Checkboxes

I have a grid that is dynamically generated based on search criteria. I render the grid in a partial view using Ajax. That all works fine.
I now need to add a checkbox column as the first column.
Also, how do I get filtering, sorting paging etc. to work now since it is in a partial view.
When i click on a header to sort I get a Page not found error and the filter Icon doesnt do anything.
And one more thing. When I try to add a GridCommandColumnSettings to the grid I get the error
"Invalid initializer member declarator"
Code is below for the gridcolumnsettings
public GridColumnSettings[] NewColumns(DataTable fullDT)
{
GridColumnSettings[] newColumns = new GridColumnSettings[fullDT.Columns.Count];
for (int i = 0; i < fullDT.Columns.Count; i++)
{
// set the visibility property for the DeliveryID
bool boolDeliveryID;
if (fullDT.Columns[i].ColumnName == "DeliveryID")
boolDeliveryID = false;
else
boolDeliveryID = true;
newColumns[i] = new GridColumnSettings
{
new GridCommandColumnSettings
{
Commands =
{
new GridEditActionCommand(),
new GridDeleteActionCommand()
},
Width = "200px",
Title = "Commands"
},
Member = fullDT.Columns[i].ColumnName,
Title = fullDT.Columns[i].ColumnName,
Visible = boolDeliveryID,
Filterable = true,
Sortable = true
};
}
return newColumns;
}
Any suggestions would be appreciated.
Thanks
I edited my post to add my partial for the Grid
Here is my partial for the grid
#(Html.Telerik().Grid<System.Data.DataRow>(Model.Data.Rows.Cast<System.Data.DataRow>())
.Name("Grid")
.Columns(columns =>
{
columns.LoadSettings(Model.Columns as IEnumerable<GridColumnSettings>);
})
.DataBinding(dataBinding => dataBinding.Ajax().Select("_DeliveryManagerCustomBinding", "Deliveries"))
.EnableCustomBinding(true)
.Resizable(resize => resize.Columns(true))
)
I don't add columns this way when I use the Telerik Grid control, but looking at what you're doing I would hazard a guess to say you will need to do something like the following:
increase the size of the newColumns array by 1 (because we're going to add in the checkbox column):
GridColumnSettings[] newColumns = new GridColumnSettings[fullDT.Columns.Count + 1];
if you want it at the beginning you will need to do the following before your for-loop:
GridColumnSettings s = new GridColumnSettings() {
ClientTemplate("<input type=\"checkbox\" name=\"checkeditems\" value=\"some value\" />")
Title("title goes in here")
};
Then you will add it into your array:
newColumns[0] = s;
and then increase the start index for your for-loop to 1:
for (int i = 1; i < fullDT.Columns.Count; i++)
the checkbox column will go at the beginning