TableView shows a column that doesn't exist - fxml

I have the following FXML code for a TableView with two columns, yet it shows three as you see in the picture. I don't see why it would show three columns, I only specified two... Any tips?
FXML
<TableView fx:id="table"
GridPane.columnIndex="1"
GridPane.rowIndex="0">
<columns>
<TableColumn fx:id="timeColumn" text="time"/>
<TableColumn fx:id="angleColumn" text="angle"/>
</columns>
</TableView>

I found out how to make the columns resize with the size of the table. Simply added this to the FXML.
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
</columnResizePolicy>

Related

Image inside label xamarin forms

I need to insert an image inside a label in Xamarin forms.
Sample: "If you find this image <image.png> you win"
I tryied to convert my png to Font and use it as Span inside the label but I failed (I don't know how to use the ttf file in the span). Any other suggestion? I prefer to avoid html view
I would say the easiest solution is a GestureRecognizer
<StackLayout>
<Label Text="Click this image" />
<Image Source="tapped.jpg" />
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Command="{Binding TapCommand}" CommandParameter="Image1" />
</StackLayout.GestureRecognizers>
</StackLayout>
more info on https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/gestures/tap

Nativescript tab layout approach

I am trying to create an app with NativeScript with the following layout:
On top, action bar
Content Area in the center (about 80% of screen height)
Fixed menu on bottom with 4 buttons
I know that NativeScript provides a TabView, however this view puts the menu on top for the android version of the app,and doesn't allow to use images as "ItemTitle".
So (I think) this leaves me with two options :
Create 4 different pages and load them when a user taps on the menu
buttons
Create one single page and change content according to user
selection
The first approach is great because I get to separate all xml , js and css files. However navigating between pages can take some time and doesn't give ideal user experience.
The second approach probably will have a better user experience but code will be very hard to maintain.
Which option should I use? Have any of you dealt with a similar layout?
Thank you for your time!
In my app I use the TabView with partial-views in each tab-item. So for each tab-view the content is separated in their own xml,js,css files.
So why not just take this approach and combine it with your option 2?
You could create a main-view with:
ActionBar
Centered main-content for partial-views (Stack- og GridLayout)
SegmentedBar at the bottom for navigation buttons
When the user taps a button on the SegmentedBar, you change the visibility of the corresponding partial-view.
You can use any font-icons as "images" for your title in the SegmentedBar also.
UPDATE: Added examples below.
How to create and reference partial-views
In your main-view Page-element add the references to each partial view, like here:
<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded"
xmlns:t1="partial-views/tab1"
xmlns:t2="partial-views/tab2"
xmlns:t3="partial-views/tab3">
Each partial view consists of a .xml, .js and perhaps a .css file. I like to place each partial view in separate folders: tab1, tab2, tab3 as an example.
The partial-view xml file would contain only the view-modules, no page-modules. So don't add any Page or ActionBar here. Example of a partial view .xml:
<GridLayout loaded="viewLoaded">
<ListView items="{{ someItemList }}">
<ListView.itemTemplate>
...
</ListView.itemTemplate>
</ListView>
</GridLayout>
How to use partial-views
Now, it's up to you how you want to use the partial-views. Here is an example on how to use them together with a TabView component. This is placed in the same page-view where you added the references from the first example.
<TabView>
<TabView.items>
<TabViewItem title="Tab 1" iconSource="res://tab1">
<TabViewItem.view>
<t1:tab1 />
</TabViewItem.view>
</TabViewItem>
<TabViewItem title="Tab 2" iconSource="res://tab2" >
<TabViewItem.view>
<t2:tab2 />
</TabViewItem.view>
</TabViewItem>
<TabViewItem title="Tab 3" iconSource="res://tab3" >
<TabViewItem.view>
<t3:tab3 />
</TabViewItem.view>
</TabViewItem>
</TabView.items>
</TabView>
Or, you could do it without the TabView, and create something custom:
<StackLayout>
<t1:tab1 id="tab1" visibility="visible" />
<t2:tab2 id="tab2" visibility="collapsed" />
<t3:tab3 id="tab3" visibility="collapsed" />
</StackLayout>
<SegmentedBar selectedIndex="0" selectedIndexChanged="segBarSelected">
<SegmentedBar.items>
<SegmentedBarItem title="Tab 1" />
<SegmentedBarItem title="Tab 2" />
<SegmentedBarItem title="Tab 3" />
</SegmentedBar.items>
</SegmentedBar>
So here would selectedIndexChangedcontrol the visibility of each partial view.

TabView vs SegmentedBar

I am creating SegmentedBar in native script. I am able to create segments but I am not able to add Label to segment view.
<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
<StackLayout>
<SegmentedBar>
<SegmentedBar.items>
<SegmentedBarItem title="Segment 1">
<SegmentedBarItem.view>
<Label text=" I am in segment bar 1"/>
</SegmentedBarItem.view>
</SegmentedBarItem>
<SegmentedBarItem title="Segment 2">
<SegmentedBarItem.view>
<Label text=" I am in segment bar 2"/>
</SegmentedBarItem.view>
</SegmentedBarItem>
</SegmentedBar.items>
</SegmentedBar>
</StackLayout>
</Page>
What is the difference between SegmentedBar and TabView as both appear same.
The Segmented bar is described in a good way by Apple:
A segmented control is a horizontal control made of multiple segments,
each segment functioning as a discrete button.
So basically: A Segmented Bar is a couple of buttons (visually) connected to each other. Just think of them like buttons with a specific look.
A TabView on the other hand the tabs (the items you click) and a connected view to each tab.
What you're doing in your code is that you're trying to combine mechanics of the TabView with the SegmentedBar.
Take a look at these two code examples.
First, the SegmentedBar. Here is an example. When you click the "First", "Second" or "Third" button nothing will happen. To react on a button press you've to bind the selectedIndex to an Observable object property and do your logic in the on the propertyChange event.
<SegmentedBar selectedIndex="{{ selectedIndex }}">
<SegmentedBar.items>
<SegmentedBarItem title="First" />
<SegmentedBarItem title="Second" />
<SegmentedBarItem title="Third" />
</SegmentedBar.items>
</SegmentedBar>
The TabView, on the other hand, consist of two things, the tabs themselves (the things you press) and a View connected to each tab. So when you click a tab the view gets changed.
<TabView>
<TabView.items>
<TabViewItem title="Tab 1">
<TabViewItem.view>
<Label text="Label in Tab1" />
</TabViewItem.view>
</TabViewItem>
<TabViewItem title="Tab 2">
<TabViewItem.view>
<Label text="Label in Tab2" />
</TabViewItem.view>
</TabViewItem>
</TabView.items>
</TabView>
These two components are used for different things. E.g. for filtering a list (show all mails, show only unread mails...) you usually use the segmented bar as you don't want to change the view - you want to change the content of the view. The TabView is used for when you actually want to display a whole new view.
You may know the <TabView> is created keeping in mind to show different pages/views in single page/view. Thus, TabView is used mainly for navigating to different views.
The SegmentedBar is created for different purpose. This can be used in a view with different functionality for example you can categorize the contents/products as Free, Paid. You would want to show different product features, services on Free view and Paid view. Thus, you can use the SegmentedBar to show different options for the user.
So, now you know the difference between the TabView and the SegmentedBar.
The correct use of SegmentedBar is to use like this:
<SegmentedBar>
<SegmentedBar.items>
<SegmentedBarItem title="Free" />
<SegmentedBarItem title="Paid" />
</SegmentedBar.items>
</SegmentedBar>
To conclude, use TabView for navigating multiple pages in single page and use SegmentedBar for viewing different content in a single view.

Configuring a filter for Devexpress ASPxGridView

I have a column named Status that display an image corresponding to states. And I have a filter on this column. How can I localize?
<dx:GridViewDataImageColumn Caption="Status" FieldName="Status" Width="100px"
ShowInCustomizationForm="True" VisibleIndex="9">
<Settings AllowSort="True" SortMode="Value" AllowHeaderFilter="True" ShowInFilterControl="True" />
<HeaderStyle HorizontalAlign="Center" />
</dx:GridViewDataImageColumn>
I am not sure that I understand your task correctly. However, it seems that you need to use the gridView's HeaderFilterFillItems event to accomplish your task.

Telerik RadGrid - How to disable sorting for a Column?

In their documentation Telerik says that there is a way to disable sorting for specific column by using AllowSorting property. I'm looking at Telerik.Web.UI.GridColumn members and there is no AllowSorting property. There is a Sortable property but its protected and has to be overriden. So what do I use to turn off sorting for specific column?
There is a AllowSorting property on GridBoundColumn but in this case I'm using GridTemplateColumn. Is there a way to turn off sorting on GridTemplateColumn?
The AllowSorting attribute is available from the source/markup view in Visual Studio. For example (simplified):
<tr:RadGrid>
<MasterTableView>
<Columns>
<tr:GridBoundColumn DataField="field" HeaderText="Description"
AllowSorting="false" />
</Columns>
</MasterTableView>
</tr:RadGrid>
I don't know if this works for you? I haven't instantiated my grids from the code-behind files yet, so if that's what you are doing, I can't easily help you. But the above works for me.
EDIT:
Ah it was not clear from the original question, that you were using the GridTemplate column. As you are now using the SortExpression-property, doesn't using the same attribute in the markup work for you? So:
<tr:RadGrid>
<MasterTableView>
<Columns>
<tr:GridTemplateColumn HeaderText="Description" DataField="field"
SortExpression="">
<!-- template here etc. -->
</tr:GridTemplateColumn>
</Columns>
</MasterTableView>
</tr:RadGrid>
Okay, I got the desired effect, I turned off sorting by setting GridTemplateColumn's SortingExpression property to blank.
Grid.Columns.FindByUniqueName("Type").SortExpression = string.Empty;
This looks like a hack. Why isn't there an explicit property to turn off sorting? Oh well. This works.
If you know a better way, let me know.
Thanks.
Telerik now has a new property called HeaderButtonType (exists on a template column too!) which can be set to "None" to render a label instead of a linkbutton for the column header text.
As stated in the Telerik Docs:
In case you want to disable sorting for a particular column only, you can configure column's IsSortable property to False:
<telerik:GridViewColumn IsSortable="False" />
Here's an example showing how to disable sorting for a specific column.
Note the AllowSorting property at the Grid level (for all columns).
Then, in the Columns collection, note how it is turned off for that specific column.
<telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="True">
<HeaderContextMenu>
<CollapseAnimation Duration="200" Type="OutQuint" />
</HeaderContextMenu>
<MasterTableView>
<RowIndicatorColumn>
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px" />
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn AllowSorting="False" UniqueName="column">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<FilterMenu>
<CollapseAnimation Duration="200" Type="OutQuint" />
</FilterMenu>
</telerik:RadGrid>
For TemplateColumns, I would try turning off Sorting at the grid level and simply enable it on the columns needed. That way, you won't have to do anything for the TemplateColumn since it will be disabled by default.
You could always supply your own headertemplate with a label as the header instead of a link button if you are using a GridTemplateColumn. A we bit extra work but this works fine. If you are going to disable sorting for all your GridTemplateColumns then your "hack" would be best.

Resources