How can I make even-width columns? - firefox

I am very perplexed with the XUL's 'Box Model' layout.
I want to make a table-like layout of elements.
The layout should consist of one row and three columns.
The columns should have the same width and occupy the whole width of the page.
I will put different elements inside the columns, but the width of the columns should remain the same
and the elements should have their normal sizes, not stretched out.
Say, first column is empty, second contains an image, third contains a button.
How can I achieve that?
I tried boxes and grids, but the columns just seem to assume arbitrary width.
Thank you.
This does not work:
<grid>
<columns flex="1">
<column/>
<column/>
<column/>
</columns>
<rows>
<row>
<spacer flex="1"/>
<image src="MyImage.png"/>
<button id="MyButton" label="MyButton"/>
</row>
</rows>
</grid>

Specify the min and max width of each column and make each cell in the grid an hbox width specific widths and heights. Something like this:
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="yourwindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:h="http://www.w3.org/1999/xhtml">
<grid>
<columns flex="1">
<column maxwidth="100" minwidth="100"/>
<column maxwidth="100" minwidth="100"/>
<column maxwidth="100" minwidth="100"/>
</columns>
<rows>
<row>
<hbox maxwidth="100">
xxxx xxxxxxxx xxxx xxxxx xxxxxxxx xxxxxxxx
</hbox>
<hbox maxwidth="100" minwidth="100" maxheight="10">
<button id="MyButton1" label="MyButton1"/>
</hbox>
<hbox maxwidth="100" minwidth="100" maxheight="30">
<button id="MyButton1" label="MyButton2"/>
</hbox>
<hbox maxwidth="100" minwidth="100" maxheight="40">
<button id="MyButton3" label="MyButton3"/>
</hbox>
</row>
</rows>
</grid>
</window>
In Xul, the width and length attributes are always in pixels. You cannot specify a percentage like you can with css. This means you will have to know your page width in advance and specify widths accordingly if you want the columns to be evenly spaced and extend to the page width.
Here's another way. Use this:
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="yourwindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml" xmlns:h="http://www.w3.org/1999/xhtml">
<grid>
<columns>
<column flex="1"/>
<column flex="1"/>
<column flex="1"/>
</columns>
<rows>
<row>
<button label="MyButton1"/>
<button label="MyButton2"/>
<button label="MyButton3"/>
</row>
</rows>
</grid>
</window>
to create this:
The buttons/columns will adjust as the window size is changed.

I suggest to use in combo with flex="1" on the column elements
<columns equalsize="always">
<column flex="1">
...
a/p documentation
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Attribute/equalsize
you can also use equalsize="always" on the rows as well, this is how it is accomplished in the Thunderbird Lightning calendar layout

Related

Nativescript Vue: Why does position of code matter in a Dock Layout matter?

Why does this following code produce this result: https://imgur.com/a/lQhLs8o ?
However, if I move the BottomNavigatorBar component to top position before CountryListComponent, it produces the desired result that looks like this: https://imgur.com/a/23z7bb2 ?
<template>
<Page actionBarHidden="true">
<DockLayout height="100%">
// first
<CountryListComponent dock="top">
// second
<BottomNavigationBar dock="bottom" activeColor="pink"
inactiveColor="yellow"
backgroundColor="black"
verticalAlignment="bottom"
#tabSelected="this.changeTab"
row="1">
<BottomNavigationTab title="Fiaarst" icon="icon-29.png" />
<BottomNavigationTab title="Second" icon="icon-29.png" />
<BottomNavigationTab title="Third" icon="icon-29.png" />
</BottomNavigationBar>
</DockLayout>
</Page>
</template>
CountryListComponent
<template>
<StackLayout backgroundColor="blue">
</StackLayout>
</template>
Refer the DockLayout documentation, by default stretchLastChild will be true which means BottomNavigationBar will take entire space if it's last child and vice versa.

DHTMLX: how to put formatting into <afterInit> section in order to have the same result in all browsers?

If I have the following my.xml file:
<rowset>
<head>
<column width="60" hidden="false" type="ro">Col A</column>
<column width="60" hidden="true" type="ro">Col B</column>
<column width="60" hidden="false" type="ro">Col C</column>
<column width="60" hidden="false" type="ro">Col D</column>
<afterInit>
<call command="attachHeader">
<param>A,B,C,D</param>
<param>color:green;,color:red;,color:blue;,color:yellow;</param>
</call>
</afterInit>
</head>
<row id="1">
<cell>value1</cell>
<cell>value2</cell>
<cell>value3</cell>
<cell>value4</cell>
</row>
<row id="2">
<cell>value5</cell>
<cell>value6</cell>
<cell>value7</cell>
<cell>value8</cell>
</row>
<row id="3">
<cell>value-11</cell>
<cell>value-12</cell>
<cell>value-13</cell>
<cell>value-14</cell>
</row>
</rowset>
and the following .html file
<body>
<div id="myGridContainer" width="799px" height="799px"></div>
</body>
<script>
myGrid = new dhtmlXGridObject('myGridContainer');
myGrid.setSkin("xp");
myGrid.xml.top="rowset";
myGrid.attachHeader("A,B,C,D",["color:green","color:red;","color:blue;","color:yellow;"]);
myGrid.load("my.xml");
</script>
then I will receive bad output in Firefox and Chrome. IE works fine. I will create the .xml manually, so I will not use .attachHeader(). But how to create the <afterInit> section with color definitions to have the same result?
Your provided code should work well. If the problem still occurs for you, please provide us a demo link or a complete demo, where the problem can reconstructed.
Instead of <afterInit> should be used <beforeInit>

ZKUI sorting by 'id' and not column

I am a zkui newbie and I have a Listmodel with live data. There is a sorting attribute that is set on the view which should sort the data by the column clicked but actually sorts by the id- sort="auto".
I found it at this site
Here is some sample code extracted from the site:
<columns menupopup="auto">
<column label="Author" sort="auto" />
<column label="Title" sort="auto" />
<column label="Publisher" sort="auto" />
<column label="Hardcover" />
</columns>
<rows>
<row>
<label value="Philip Hensher" />
<label value="The Northern Clemency" />
<label value="Knopf (October 30, 2008)" />
<label value="608 pages" />
</row>
<rows>
I researched a solution but I only found similar unanswered questions like the one here
I wonder if the issue might be the fact that I'm working with live data.
Please tell me what to do to ensure that the data is sorted according to the clicked column.
I am using grails to develop the application and this is my list.gsp:
<z:grid id="grid"
emptyMessage="${message(code:'emptyMessage',default:'No Record')}">
<z:columns sizable="true">
<z:column
label="${message(code: 'app.name.label', default: 'Name')}" sort="auto" />
<z:column
label="${message(code: 'app.status.label', default: 'Status')}" sort="auto"/>
In your list.gsp, try specifying the object attribute to be used in the sorting, like sort="auto(app.id)", sort="auto(app.name)" or whatever.

100% height XUL elements

I have this deck in a Firefox sidebar (XUL):
<deck id="mydeck" selectedIndex="0">
<vbox id="myscreen1">
...
</vbox>
<vbox id="myscreen2">
<vbox flex="3" minheight="150">
...
</vbox>
<splitter collapse="after" resizeafter="farthest">
<grippy height="10" align="end" />
</splitter>
<vbox flex="1" minheight="125">
...
</vbox>
</vbox>
</deck>
I'm trying to get #myscreen2 to take up the whole sidebar vertically. How do I achieve this?
Right now it only uses the minimum height set for the two boxes. I've tried to set height: 100% and flex="1" on the deck itself and #myscreen2, but it's not working.
I really don't like the available XUL documentation, but I managed to come up with a solution:
<deck id="mydeck" selectedIndex="0" flex="1">
<vbox id="myscreen1">
...
</vbox>
<vbox id="myscreen2">
<vbox flex="3" minheight="150">
...
</vbox>
<splitter collapse="after" resizeafter="farthest">
<grippy height="10" align="end" />
</splitter>
<vbox flex="1" minheight="125">
...
</vbox>
</vbox>
</deck>
The key was to have flex="1" on the deck. Not sure why it wasn't working when I tried it the first time.

Getting XUL:Scale to show what numeric value is selected

I'm working with XUL, and below is abasic slider/scale implementation:
<scale value="1" min="1" max="10" increment="1"/>
However I want a numbox next to it which displays the value selected in the slider, and maybe I didn't look hard enough in the XUL tutorial, but I couldn't find a feasible answer.
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="yourwindow"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<scale value="1" min="1" max="10" increment="1" id="a"/>
<textbox readonly="true" observes="a"/>
</window>

Resources