Layout trouble with CUBA screen designer - cuba-platform

I am testing the Cuba-Platform and I have trouble understanding the layout options within the screen designer.
I am trying to spread tables and twincolumns evenly and aligned over the screen. (And add a label on top of each)
The simplest task of stretching the containers (vbox and hbox) is difficult.
When I set height/width to 100% the items within are evenly distributed within the space. When I now try to set the height of the table within the vbox to 100% (hoping it would stretch) it gets reset to 100px.
I also tried the grid component, but when I set it to 100% the columns are have all the same hight (no good for label)
Maybe my understanding (coming from xaml/c# and the ms-components) is completely wrong. Please tell me, how can I create a view and ensure:
that the components are at the same height (stretched if need be)
that the components are aligned
that the whole screen is filled
label label
table twincolum
okcancel
As requested a simple image - of what by now drives me crazy..
Id like to add some code I eventually came up with - Its not yet the ideal thing:
<layout>
<hbox id="hboxexpand"
expand="assignTwinCol"
height="100%"
spacing="true"
width="80%">
<table id="userTable"
height="100%"
**width="auto"**>
<columns>
<column id="value1"
caption="msg://1"/>
<column id="firstName"
description="msg://firstNameHeader"/>
<column id="lastName"
caption="msg://nameHeader"/>
<column id="active"
caption="msg://activeHeader"/>
</columns>
<rows datasource="userDs"/>
</table>
<twinColumn id="assignTwinCol"
addAllBtnEnabled="true"
height="100%"
optionsDatasource="myDs"/>
</hbox>
</layout>
Please note: When I use the designer the **** part width=auto will be reset to 200px every time! I can only change that in the xml designer

Table does not have full support of AUTO width because width of columns can be adjusted by content, so I would recommend using fixed or relative width for a table.
<layout>
<hbox expand="twinColumn"
height="100%"
spacing="true"
width="100%">
<table id="userTable"
height="100%"
width="400px">
<columns>
<column id="firstName"/>
<column id="lastName"/>
<column id="active"/>
</columns>
<rows datasource="usersDs"/>
</table>
<twinColumn id="twinColumn"
addAllBtnEnabled="true"
optionsDatasource="usersSelectDs"
height="100%"/>
</hbox>
</layout>
If you want to set headers for TwinColumn columns you can use unwrap methods and Vaadin API of TwinColSelect:
public class Screen extends AbstractWindow {
#Inject
private TwinColumn twinColumn;
#Inject
private Table<User> userTable;
#Override
public void init(Map<String, Object> params) {
super.init(params);
TwinColSelect colSelect = twinColumn.unwrap(TwinColSelect.class);
colSelect.setLeftColumnCaption("Header Left");
colSelect.setRightColumnCaption("Header Left");
Layout tableComposition = userTable.unwrapComposition(Layout.class);
tableComposition.setCaption("Table Header");
}
}
We need to align our headers of the Table and TwinColumn. Table caption does not have padding-bottom 0.3em that TwinColumn headers have. We can add padding using stylename for the table:
<table id="userTable"
height="100%"
width="400px"
stylename="padding">
<columns>
<column id="firstName"/>
<column id="lastName"/>
<column id="active"/>
</columns>
<rows datasource="usersDs"/>
</table>
Then we create theme extension using Studio and add CSS definition to halo-ext.scss file:
.v-caption.v-caption-padding {
padding-bottom: 0.3em;
}
Now restart the application and our headers are aligned!
CUBA Team are planning to add caption and leftColumnCaption/rightColumnCaption attributes for components in the next minor release and you will be able to assign them from XML/Screen Designer.
See also:
https://doc.cuba-platform.com/manual-6.2/webComponentsHelper.html
https://vaadin.com/api/com/vaadin/ui/TwinColSelect.html

Related

Xpages and Bootstrap - Pager is not aligned

My pagers will not align correctly on an Xpages view. The blank table cells on the left and right are huge.
Any help would be greatly appreciated:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xe="http://www.ibm.com/xsp/coreex">
<div
class="panel panel-default">
<!-- Default panel contents -->
<div
class="panel-heading">Panel heading</div>
<xp:viewPanel
rows="30"
id="viewPanel1"
viewStyleClass="table"
var="rowData">
<xp:this.facets>
<xp:pager
partialRefresh="true"
layout="Previous Group Next"
xp:key="headerPager"
id="pager1" />
</xp:this.facets>
<xp:this.data>
<xp:dominoView
var="view1"
viewName="(PC)" />
</xp:this.data>
<xp:viewColumn
id="viewColumn1">
<xp:this.value><![CDATA[#{javascript:""}]]></xp:this.value>
<xp:link
escape="true"
id="link1"
value="">
<xp:this.text><![CDATA[#{javascript:rowData.getColumnValue("serialNumber");}]]></xp:this.text>
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete">
<xp:this.action>
<xp:openPage
name="/xpPCForm.xsp"
target="openDocument">
<xp:this.documentId><![CDATA[#{javascript:rowData.getDocument().getUniversalID()}]]></xp:this.documentId>
</xp:openPage>
</xp:this.action>
</xp:eventHandler>
</xp:link>
<xp:viewColumnHeader
id="viewColumnHeader1"
sortable="true"
value="Serial Number" />
</xp:viewColumn>
</xp:viewPanel>
</div>
</xp:view>
=============================================================
I am still getting a space where I don't want it. Not horrible, but I do not like not knowing why something is occurring.
As you can see there is space to the left of the pager. It is a table column. I tried Bryan's suggestion and used several of the other facets, but that didn't work either. If I put the pager in northWest, then the first column of the table was extremely wide.
Oliver's suggestion shrunk the margin for top and bottom (so closer to the button and closer to the start of the view, but no change to the left column).
Just baffled as to why it is doing this?
You should use a different facet for the pager on the view panel. Sven Hasselbach had a good blog post explaining the layout of the various viewPnael facets: http://hasselba.ch/blog/?p=793. These additional facets explain why you can see empty table cells in firebug.
So you could try using the North or Northwest facets, instead of the headerPager facet:
<xp:this.facets>
<xp:pager
partialRefresh="true"
layout="Previous Group Next"
xp:key="north"
id="pager1" />
</xp:this.facets>
UPDATE:
If sticking with the headerPager facet and viewStyleClass="table", you could work around the spacing in a few ways.
Make that first empty TD invisible
.panel > .table > tbody > tr:first-child > td:first-child {
display:none;
}
Or re-style the pager to alter its position:
<xe:pagerSizes id="pagerSizes1"
xp:key="headerPager"
style="left:-20px;position:relative;">
</xe:pagerSizes>
In both cases, adding Oliver's suggested margin change helps too.
Usually I add this to my CSS:
.pagination {
margin: 0;
}
Though I've never seen those big spaces...

Creating fixed FCE with fluidcontent

Width this code i can define content:
<flux:flexform.section name="columns">
<flux:flexform.object name="column" label="column">
<flux:flexform.field.input name="demo" label="Demo field" />
</flux:flexform.object>
</flux:flexform.section>
<flux:flexform.grid>
<flux:flexform.grid.row>
<f:for each="{columns}" as="sectionObject" iteration="iteration">
<flux:flexform.grid.column>
<flux:flexform.content name="column{iteration.cycle}" label="Column {iteration.cycle}" />
</flux:flexform.grid.column>
</f:for>
</flux:flexform.grid.row>
</flux:flexform.grid>
This is flexible. I can Add new "Content Areas" through the section. But this is not what I want. I Want to define a very fixed two-column and a three-column FCE. My editor should not have to decide how many columns to use.
I am missing something like:
<flux:flexform.field.contentArea name="col1" label="Column 1" />
<flux:flexform.field.contentArea name="col2" label="Column 2" />
<flux:flexform.grid>
<flux:flexform.grid.row>
<flux:flexform.grid.column>
<flux:flexform.content name="col1" />
</flux:flexform.grid.column>
<flux:flexform.grid.column>
<flux:flexform.content name="col2" />
</flux:flexform.grid.column>
</flux:flexform.grid>
</flux:flexform.grid.row>
Thank you for your hint to the right direction.
You are very close to the solution with the code you already have. In this example I will use the new ViewHelper names - but you can get the same result using the old names as in your example. Which is which, should be easy to spot (note: you had a typo in your code example which I edited, rgid used instead of grid - such a typo would cause Flux to error out):
<flux:grid>
<flux:grid.row>
<flux:grid.column>
<flux:content name="col1" label="Nice name for column 1" />
</flux:grid.column>
<flux:grid.column>
<flux:content name="col2" label="Column 2" />
</flux:grid.column>
</flux:grid>
</flux:grid.row>
And remove the flux:form.section with object inside it - you don't need this when you make a statically defined grid.
Then to render this grid:
<flux:content.render area="col1" /> and so on.

Struts 2 Jquery delete a row

Can anyone help me deleting a row from Struts 2 Jquery grid using an external button.
I have included a button in the jsp as below
<sj:a id="delete" name="delete" onClickTopics="rowselect"
button="true">Delete</sj:a>
and in the script tag I have written
$.subscribe('delete', function(event,data) {
$("#gridedittable").jqGrid(‘delRowData’,row_id);
}
I am not able to get the rowid for the selected row to be deleted.
Can any one help me with this as I am new to struts 2 jquery.
Hi you can get selected row by using the jqGrid api
$.subscribe('delete', function(event,data) {
var rowid = $("#gridedittable").jqGrid(‘getGridParam’,'selrow');
$("#gridedittable").jqGrid(‘delRowData’,row_id);
}
This assumed you set the multiselect param to false.
For multiselect , you have to use the option selarrrow instead.
http://www.trirand.com/jqgridwiki/doku.php?id=wiki:methods
http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options
And the grid setting should be like
<s:url var="remoteurl" action="jsontable"/>
<sjg:grid
id="gridtable"
caption="Customer Examples"
dataType="json"
href="%{remoteurl}"
pager="true"
gridModel="gridModel"
rowList="10,15,20"
rowNum="15"
rownumbers="true"
>
<sjg:gridColumn name="id" index="id" title="ID" key="true" sortable="false"/>
<sjg:gridColumn name="name" index="name" title="Name" sortable="true"/>
<sjg:gridColumn name="country" index="country" title="Country" sortable="false"/>
<sjg:gridColumn name="city" index="city" title="City" sortable="false"/>
<sjg:gridColumn name="creditLimit" index="creditLimit" title="Credit Limit" formatter="currency" sortable="false"/>
</sjg:grid>

Making asp:Label a specific HTML tag

New to VB.net, just trying to figure out how to properly manipulate the asp:Label control.
I have a page that, based on if there are results, etc should display an <h1></h1> tag with a header, then the data. As I am using the code-behind model, my user facing page essentially just has the following:
<asp:Label ID="lblMessage" runat="server"
Visible="false" />
<asp:DataList ID="dlCurriculumLists" runat="server"
DataSourceID="sdsCurriculumLists"
DataKeyField="Entry No_"
RepeatLayout="Flow"
Visible="false">
<ItemTemplate>
<div>
<asp:HyperLink ID="hlCurriculum" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "Title") %>'
NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "File Path") %>'
ToolTip='<%# DataBinder.Eval(Container.DataItem, "Title") %>'
Target="_blank"
Style="font-weight: bold;">
</asp:HyperLink>
</div>
</ItemTemplate>
</asp:DataList>
On my code-behind page, I then set the asp:Label and asp:DataList to Visible="true" based on the data from the database. Here's the catch - if there is data, I want to set lblMessage to be an H1, and if not, just standard Label text. I realize I can emulate the look through the CSS, but was just hoping there was another way (maybe similar to the ItemTemplate concept) to specify the HTML type of the Label control - it appears to be a by default.
For people coming from a VB background, it's a common mistake to think that the most basic control for displaying arbitary text is a Label.
That's not true. A label should label something, usually another UI control (that's what the AssociatedControlId property is for).
If you just want to display arbitrary text or HTML markup, use something more basic instead. Some examples are asp:Literal, asp:Placeholder or asp:Localize.
Using, for example, an asp:Literal called myLiteral, you can easily create a heading in code:
myLiteral.Text = "<h1>" & Server.HtmlEncode(myHeading) & "</h1>"
As far as I know, the asp:Label component will always generate a <label> HTML tag when its AssociatedControlId attribute is set.
What you could do instead is use a Literal Control and populate it with the HTML you wish at runtime.
UPDATE
One thing you could do to make this work as required using your current Label control is to have a theme for the label that marks it up as a H1. You could then toggle the controls EnableTheming property as required.
Aside from what already has been suggested here, you can also implement your own ASP.NET control with any properties you want, then modify its rendering on the fly, depending on the properties' values. It is pretty fun to do and is not as hard as one might think. Here is some information on the subject: http://msdn.microsoft.com/en-us/library/vstudio/zt27tfhy(v=vs.100).aspx

Flex - returning a window to its original state

I have been tearing my hair out now for a week or so, it's time I sought some help...
I am coding a small app to show me the next train leaving the station. Normally only the hour of the next train is shown, but if you click on the prefs button, the application window enlarges and a datagrid is shown with the trains and hours. Clicking on the close button in that state returns you to the 'start' state, or should do so.
The problem is that the datagrid disappears, but the application window stays the same size. It should return to it's original size.
I've been trying lots of different approaches, replacing VBoxes by Canvas or Panels but none worked. In design mode everything work as expected when switching between states.
This is the first time I've been using states, so I might be missing something fundamental.
Here's a code sample - I'm using 2 view states, Start and Prefs.
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="init();"
cornerRadius="12"
currentState='Start' width="350" height="250">
<mx:states>
<mx:State name="Start">
<mx:AddChild>
<mx:VBox id="box_parent" width="100%" height="100%" verticalGap="2">
<mx:Label text="Next Train Leaves At" textAlign="center" width="100%"/>
<mx:Label text="--:--" width="100%" height="100" fontSize="64" id="timetext" textAlign="center" fontWeight="bold"/>
<mx:HBox width="100%" height="25" id="hbox1">
<mx:Button label="Prefs"
id="buttonPrefs"
click="currentState='Prefs'"/>
<mx:Spacer width="70%" id="spacer1"/>
<mx:Button
label="Next"
click="findNextTrain()" id="buttonNext"/>
</mx:HBox>
</mx:VBox>
</mx:AddChild>
<mx:SetProperty name="layout" value="vertical"/>
<mx:SetProperty name="width" value="350"/>
<mx:SetProperty name="height" value="220"/>
</mx:State>
<mx:State name="Prefs" basedOn="Start">
<mx:AddChild relativeTo="{box_parent}" position="lastChild">
<mx:DataGrid height="80%" width="100%" dataProvider="{trains}" id="traindata" editable="false">
<mx:columns>
<mx:DataGridColumn headerText="Station" dataField="stationid"/>
<mx:DataGridColumn headerText="Leave" dataField="leave"/>
</mx:columns>
</mx:DataGrid>
</mx:AddChild>
<mx:RemoveChild target="{buttonPrefs}"/>
<mx:SetProperty target="{box_parent}" name="height" value="500"/>
<mx:AddChild relativeTo="{spacer1}" position="before">
<mx:Button label="Close" click="currentState='Start'"/>
</mx:AddChild>
<mx:SetProperty name="height" value="570"/>
</mx:State>
</mx:states>
<mx:transitions>
<mx:Transition fromState="*" toState="*">
<mx:Resize target="{this}" duration="500"/>
</mx:Transition>
</mx:transitions>
</mx:WindowedApplication>
I have yet to find a way to reset a state in Flex to the values provided in the MXML. You have to reset what values you need your self programmatically. In the case of the provided sample code, you can reset the height of the application when changing back to the start state by adding the following into the WindowedApplication tag
currentStateChange="if(currentState == 'Start') this.height = 220"
This tells the WindowedApplication tag to handle the event dispatched after changing the current state to check if the new current state is Start, and to set the window height if it is.