I am trying to add a checkbox to a List component in my application and everything works seeming well until I scroll through my data.
As I scroll vertically in my List, any checks I may have added start to get added to other items in my List, sometimes the original item I checked is not even checked anymore.
For example, my List height is enough to see 5 items, I check Item 1, scroll down and every 5th item starts to get checked.
It's really odd and I have not been able to figure out why it is doing this. I looked at some examples online, and I'm not doing anything any different as far as I can tell.
I ran some traces and the Checkbox datachange event fires as I scroll through my list, but again, I am not sure why.
Here is the mxml test page for my List.
Any help is appreciated, thanks.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Array id="arr">
<mx:Object label="One" />
<mx:Object label="Two" />
<mx:Object label="Three" />
<mx:Object label="Four" />
<mx:Object label="Five" />
<mx:Object label="Six" />
<mx:Object label="Seven" />
<mx:Object label="Eight"/>
<mx:Object label="Nine" />
<mx:Object label="Ten" />
<mx:Object label="Eleven" />
<mx:Object label="Twelve" />
</mx:Array>
<mx:List
id="addrList"
height="100"
width="100%" fontSize="10"
borderStyle="solid"
borderColor="#000000"
borderThickness="1"
dataProvider="{ arr }">
<mx:itemRenderer>
<mx:Component>
<mx:CheckBox
change="trace('change')"
dataChange="trace('dataChange')"/>
</mx:Component>
</mx:itemRenderer>
</mx:List>
</mx:Application>
your putting an object to a list dataprovider, dataprovider supports text only
try this
<mx:Script>
<![CDATA[
[Bindable]
private var arr:Array = ["a","b","c","d","e","f","g"];
]]>
</mx:Script>
<mx:List
id="addrList"
height="100"
width="100%" fontSize="10"
borderStyle="solid"
borderColor="#000000"
borderThickness="1"
dataProvider="{ arr }">
<mx:itemRenderer>
<mx:Component>
<mx:CheckBox change="trace('change')"
dataChange="trace('dataChange')"/>
</mx:Component>
</mx:itemRenderer>
</mx:List>
Related
Using this code:
<tabView:SfTabView x:Name="tabView"
TabWidthMode="SizeToContent">
<tabView:SfTabView.Items>
<tabView:SfTabItem Header="Item" />
<tabView:SfTabItem Header="Item" />
<tabView:SfTabItem Header="Item" />
<tabView:SfTabItem Header="Item" />
</tabView:SfTabView.Items>
</tabView:SfTabView>
The result looks like this:
I could not figure out, how I can remove the gab (margin and padding do not effect it).
Any help would be appreciated.
I created a sap.m.table with its header headerToolbar.
In the header, I put the title and two SelectList separated by a ToolbarSpacer.
The problem is that when the screen size is small the elements on the headerToolbar don't go back to the next line and are truncated ...
On a large screen:
On a small screen:
I want the header to be responsive, that is the elements should go to the next line if there is no sufficient space.
Here is the code:
<headerToolbar height="auto">
<Toolbar height="auto">
<content>
<Title id="tableHeader" text="..."/>
<ToolbarSpacer />
<Label text="..." lableFor="sl1"/>
<SelectList id="sl1"
enabled="true">
<core:Item key="..." text="..." />
<core:Item key="..." text="..." />
</SelectList>
<ToolbarSpacer />
<Label text="..." lableFor="sl2"/>
<SelectList id="sl2"
enabled="true">
<core:Item key="..." text="..." />
<core:Item key="..." text="..." />
</SelectList>
<ToolbarSpacer />
</content>
</Toolbar>
</headerToolbar>
Why you don't use OverflowToolbar instead of Toolbar?
Is the official responsive Toolbar
https://sapui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.OverflowToolbarFooter/preview
If you don't like it and want this "pop-in" behaviour you have described, I guess you can put a FlexBox inside your Toolbar and set the direction property depending on the "device" model.
Using expression binding will be something like this:
new sap.m.FlexBox({
direction: "{= ${device>/isPhone} ? 'Column' : 'Row' }",
items: [
//Your content goes here
]
})
More here: https://sapui5.hana.ondemand.com/#docs/guide/69a8e469fbde46e7b8916250080effbd.html
You can enable horizontal table scrolling in the css:
.enableTableScrolling {
overflow-x: scroll;
}
After that table will not be truncated.
I am having an un-predictable behavior of creating radio buttons in advancedDataGrid column using itemRenderer. Similar kind of problem has been reported at
Creating a column of RadioButtons in Adobe Flex. I tried to use the same procedure i.e. bind every radio button selectedValue and value attributes with the property specified in the property of the associated bean but still facing the problem.
The button change values! The selected
button becomes deselected, and
unselected ones become selected.
Here is the code of my advancedDataGrid:
<mx:AdvancedDataGrid id="adDataGrid_rptdata"
width="100%" height="100%"
dragEnabled="false" sortableColumns="false"
treeColumn="{action}"
liveScrolling="false"
displayItemsExpanded="true" >
<mx:dataProvider>
<mx:HierarchicalData source="{this.competenceCollection}" childrenField="competenceCriteria"/>
</mx:dataProvider>
<mx:columns>
<mx:AdvancedDataGridColumn headerText="" id="action" dataField="criteriaName" />
<mx:AdvancedDataGridColumn headerText="Periode 1" dataField="" width="200">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center" width="100%" verticalAlign="middle">
<mx:RadioButton name="period1" value="{data}" selected="{data.period1}" group="{data.radioBtnGrpArray[0]}" visible="{data.showRadioButton}" />
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
<mx:AdvancedDataGridColumn headerText="Periode 2" dataField="" width="200">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center" width="100%" verticalAlign="middle">
<mx:RadioButton name="period2" value="{data}" selected="{data.period2}" group="{data.radioBtnGrpArray[1]}" visible="{data.showRadioButton}" />
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
<mx:AdvancedDataGridColumn headerText="Periode 3" dataField="" width="200">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center" width="100%" verticalAlign="middle">
<mx:RadioButton name="period3" value="{data}" selected="{data.period3}" group="{data.radioBtnGrpArray[2]}" visible="{data.showRadioButton}" />
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
</mx:columns>
</mx:AdvancedDataGrid>
Any work around is highly appreciated in this regard!
The selected button becomes deselected, and unselected ones become selected.
Is this problem occurring only for those radio buttons whose selected state was manually changed by the user? In that case it is because flex resets its selected state based on the value mentioned in the declaration when a RadioButton is reused. So even if you select/deselect a ratio button in the Periode 1 column, flex resets it to {data.period1} when you scroll away and come back. Making the column editable to save the modifications back to the data provider might work. Try changing the column declaration to:
<mx:AdvancedDataGridColumn headerText="Periode 1" dataField="" width="200"
editable="true" rendererIsEditor="true" editorDataField="selected">
EDIT: Try this - attempting to change the data provider when the radio button is selected. code written from memory and not tested - might contain bugs.
<mx:AdvancedDataGridColumn headerText="Periode 1" dataField="" width="200">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center" width="100%"
verticalAlign="middle">
<mx:RadioButton id="rb" name="period1" value="{data}"
selected="{data.period1}"
group="{data.radioBtnGrpArray[0]}" visible="{data.showRadioButton}"
change="outerDocument.handleRadio1(this);"/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
//in a script tag outside the datagrid.
public function handleRadio1(renderer:IListItemRenderer):void
{
var index:Number = adDataGrid_rptdata.itemRendererToIndex(renderer);
this.competenceCollection[i].period1 = renderer.rb.selected;
}
I have this HBox with drop functionality:
SCRIPT:
// The dragEnter event handler for the HBox container enables dropping.
private function dragEnterHandler(event:DragEvent):void
{
if (!event.dragSource.hasFormat("items"))
return;
var dropTarget:Box = Box(event.currentTarget);
dropTarget.setStyle("borderStyle", "outset");
DragManager.acceptDragDrop(dropTarget);
DragManager.showFeedback(DragManager.MOVE);
}
private function dragExitHandler(event:DragEvent):void
{
if (!event.dragSource.hasFormat("items"))
return;
var dropTarget:Box = Box(event.currentTarget);
dropTarget.setStyle("borderStyle", "inset");
}
MXML
<mx:HBox id="invoiceHBox" borderStyle="inset" borderThickness="3"
height="40" width="260"
dragEnter="{dragEnterHandler(event);}"
dragExit="{dragExitHandler(event);}"
dragDrop="{dragDropHandler(event);}">
<mx:VBox>
<mx:Image source="{MailIcon32}" visible="{Boolean(invoiceEmail)}" />
<mx:Label text="{invoiceEmail.name}" styleName="heading4" />
<mx:Text text="{invoiceEmail.description}"
width="100%" selectable="false" />
</mx:VBox>
</mx:HBox>
When the mouse enters the HBox, it works fine. The data can be dropped into the HBox and the function dragDropHandler (a very long function) does its work.
However, when the mouse hovers over the VBox, the drop functionality is lost. Can the VBox container somehow inherit from the HBox? or is there another solution to this problem?
thanks!
You need to disable the mouseChildren property of the HBox and it should work
<mx:HBox id="invoiceHBox" borderStyle="inset" borderThickness="3"
height="40" width="260"
dragEnter="{dragEnterHandler(event);}"
dragExit="{dragExitHandler(event);}"
dragDrop="{dragDropHandler(event);}"
mouseChildren="false" >
<mx:VBox>
<mx:Image source="{MailIcon32}" visible="{Boolean(invoiceEmail)}" />
<mx:Label text="{invoiceEmail.name}" styleName="heading4" />
<mx:Text text="{invoiceEmail.description}"
width="100%" selectable="false" />
</mx:VBox>
</mx:HBox>
I've got a "popup" context menu on a list box, and there are two behaviors that would seem "out-of-the-box" but I am having a tough time getting the XAML ContextMenu to behave the way I would expect...
One is that, when I pick a sub-menu (e.g. "One" or "Two"), the initial menu continues to stay open (e.g. "Menu" does not go away once I've made a selection).
Second is that the menu margins seem odd. Left justifying Horizontally does not seem to make the main menu (e.g. "Menu") left justify... I can work around this by tweaking the margin - but thats painful for dynamic text..
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<StackPanel>
<ListView>
<ListView.ContextMenu>
<!-- StaysOpen="False" -->
<ContextMenu>
<!-- Background="Transparent" Margin="-8,0,-8,0" -->
<Menu>
<!-- StaysOpenOnClick="False" -->
<MenuItem Header="Menu">
<MenuItem Header="One" />
<MenuItem Header="Two" />
</MenuItem>
</Menu>
</ContextMenu>
</ListView.ContextMenu>
<ListViewItem Content="Red" />
<ListViewItem Content="Orange" />
<ListViewItem Content="Black" />
<ListViewItem Content="Blue" />
<ListViewItem Content="Green" />
</ListView>
</StackPanel>
</Page>
Any thoughts on how to make the Main menu of this popup behave?
Thanks in advance,
T
Try this:
<ContextMenu>
<MenuItem Header="Menu">
<MenuItem Header="One" />
<MenuItem Header="Two" />
</MenuItem>
</ContextMenu>
you are not supposed to have a menu inside a context menu.
you should put menuitem directly.