flex 3 using nested repeaters - flex3

I'm trying to loop through a row of an arraycollection using nested repeater;
<mx:Repeater id="rp1" dataProvider="{arrayCollection}">
<mx:Repeater id="rp2" dataProvider="{rp1.currentItem}">
<mx:Button height="49" width="50" label="{rp2.currentItem.name}" />
</mx:Repeater>
</mx:Repeater>
What im trying to do is make the repeater loop through all the attributes in the currentRow, eg. name,age, address etc. At the moment all i do is call rp2.currentItem.name which explicitly calls out the name of the attribute and then the value is returned.
Is it possible instead of explicity naming the attribute to just loop through them all and dispplay button for each using the nested repeater?thanks

Do you want a single Repeater for all objects of your ArrayCollection? Use a custom component.

Related

How can I add a Datagrid reflecting currect state of ReferenceArrayInput to a react-admin edit form?

I'm writing a user management using react-admin and try to make adding users to groups easier, i.e. by adding groups from a user's edit page using auto-complete. Starting with an example, I've got some success using the following:
<ReferenceArrayInput
label="Group"
source="groups"
reference="groups"
>
<AutocompleteArrayInput
{...props}
resettable={true}
allowEmpty={true}
optionText="name"
fullWidth
/>
</ReferenceArrayInput>
However, this method uses Chip component to display selected items inline. I would like to use a Datagrid instead. I know from the source code that I cannot override the display part of an auto-complete (yet?), so I thought I could resort to hiding Chips via CSS, but I would still need a way to display a Datagrid with current selection. So I tried this (it's wrapped in FormWithRedirect, hence formProps):
<ReferenceArrayField
{...formProps}
label="Group"
source="groups"
reference="groups"
>
<Datagrid>
<TextField source="name" />
</Datagrid>
</ReferenceArrayField>
<ReferenceArrayInput
{...formProps}
label="Group"
source="groups"
reference="groups"
>
<AutocompleteArrayInput
resettable={true}
allowEmpty={true}
optionText="name"
fullWidth
/>
</ReferenceArrayInput>
This works almost exactly as I want it, a Datagrid is displayed and it shows the right data for the selection, however, it's not updated when selected items on AutocompleteArrayInput change. How ever I tried (been through probably all the hooks and contexts), I could not make it work.
Is this possible? How can I make Datagrid update when selection changes on AutocompleteArrayInput?

Using inner component in a loop in Shopware 6 does not persist the values uniquely for each looped component

I am using a v-for over a custom component and passing the item as a prop. But the issue is that each component instance in the loop takes the same item prop. For e.g in the 1st loop a component field has text "abc", then the second looped component also will have the same "abc" text. If I change the text in the 2nd one, it changes in the 1st component too. Is there a way to make the prop unique for each loop ?
For e.g this is the code which calls the inner component:
<template v-for="(businesscase, index) in businessCase.fields">
<custom-case-freetext-field #field-changed="updateFields"
:key="index"
#field-removed="removeFields"
:fields="businessCase.fields"
:index="index">
</custom-case-freetext-field>
</template>
and inside this component I have a basic form
<sw-field :label="$tc('rma.modules.case.freetext.nameLabel')"
:placeholder="$tc('rma.modules.case.freetext.nameLabel')"
required
v-model="fields[index].name">
</sw-field>
<sw-single-select
labelValue="label"
valueProperty="label"
:options="fieldTypes"
:label="$tc('rma.modules.case.freetext.fieldType')"
:placeholder="$tc('rma.modules.case.freetext.fieldType')"
v-model="fields[index].type"
#input="changeType"
required>
</sw-single-select>
If I do :value instead of v-model, the entered value disappears as soon as the element loses focus.
If I use v-model, the data stays there, but then both (or as many are there in the loop) component instances, have data binding between them, so it defeats the purpose of having a loop for multiple components. As seen in the screenshot, I am typing in the 2nd component, but it changes the text for the first one too.
In the above example I am sending the whole array as prop, but I have also tried with individual field element instead of fields
Your are not using the businesscase variable inside your components. And since every component always works on the upper scope property, they will all change the same. Use the innerscope property. If you have problems with reactivity, because you try to mutate props directly work with events emitting the key and the changed value to the upperscope component.

How to format label in Xamarin XAML Listview based on a viewmodel attribute

I am trying to create a ListView cell data template with a label that shows either a "detailed" description or a "short" description based on whether another variable ViewLevel is "Detailed" or "Short".
I am using an IValueConverter and trying to bind the ConverterParameter, but that does not work as I don't think the ConverterParameter is bindable.
Is there a best practice for doing this?
The label I currently have is:
<Label Binding Options, Converter={viewModels:DetailLabelConverter}, ConverterParameter='Detail'}" />
It works, but obviously has the hardcoded Detail view. I've also tried:
<Label Text="{Binding Options, Converter={viewModels:DetailLabelConverter}, ConverterParameter={Binding Source={x:Reference BasePage}, Path=BindingContext.ViewLevel}}"/>
Which works, insomuch as it calls the DetailLabelConverter. Unfortunately the parameter is not loaded with the value of ViewLevel but a Xamarin.Forms.Binding object.
It seems like this should be a fairly common pattern but I can't find a reasonable solution.

How to display data in struts form if object has another object

I'm working on struts 1.3 framework application.
I have one object which I'm setting in request attribute.
request.setAttribute("school",school);
And I'm trying to display that object through <bean:define> tag.
E.g.
School is Value Object
School school;
in school VO object I have another two object
Student student;
Teacher teacher;
And I'm trying to display value of student as well as teacher object
<bean:define id="summary" name="school" />
<bean:define id="StudentSummary" name="summary" property="student"/>
<bean:define id="TeacherSummary" name="summary" property="teacher"/>
And writing this element through tag
<bean:write name="StudentSummary" property="name" />
<bean:write name="StudentSummary" property="class" />
<bean:write name="TeacherSummary" property="name" />
But it is giving
javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE
what would be wrong in the code.
I have never done it using bean tag but you can do it using Expression language(EL). EL, I believe is a more standard way to do things.
Take a look at this previous post. I think it helps Link
I think in your case you can do something along the line of
<c:out value="${school.student.name}"/>
The above statement will print the value of "name", if you have a "name" property in your student object.

GridView-like page but with static groups and each group section will have a different layout

I would like to create a page a little like the Grouped Items Page inside the Contoso Cookbook application (if you have seen it). Basically, it's a GridView bound to a CollectionViewSource.
<CollectionViewSource
x:Name="groupedItemsViewSource"
Source="{Binding Groups}"
IsSourceGrouped="true"
ItemsPath="TopItems"
d:Source="{Binding AllGroups, Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}"/>
The GridView appears to bind the Groups to the highest level of the CVS data source with the Source attribute and then binds each individual section with the ItemsPath attribute.
However, my page differs in that my groups are static, they are: Times, Categories, List. The first will have a listview, the second a grid of tiles and the third will be another listview.
Also, each group section itself has a different layout. It's not just repeating groups and repeating item-layouts. I was expecting to be able to define "static" groups and a layout for each group directly in the XAML and maybe even add test data to those elements, but it seems like GridView requires data binding, even if just to a dummy data source at design time.
So how would you do this? So essentially, it needs exactly the same horizontal scroll and wrapping as the GridView, but the groups have totally different layouts and each group should ideally be definable directly in the XAML?
I'm thinking of creating a normal grid enclosed in a scroll viewer... what do you think? What would you do?
In a GridView, groups can be assigned a GroupStyle like this:
<GridView.GroupStyle>
<GroupStyle HeaderTemplate="{StaticResource MyGroupHeaderTemplate}"
Panel="{StaticResource MyGroupItemsPanelTemplate}"
HidesIfEmpty="True" />
</GridView.GroupStyle>
Now, in your case each group will need its own GroupStyle.
So instead of using a ListView within each group in a GridView, you could:
Define 2 different group styles with header templates and the panel (ItemsPanelTemplate (MSDN)) that you want to use
Define a class that has your custom logic to select which group style to use for a group.(GroupStyleSelector)
Set the GroupStyleSelector property on the GridView in XAML
Define static groups in your view model to contain the data you want: (Times, Categories, List)
This can be accomplished with a DataTemplateSelector. You would have multiple groups, but within each group the items are styled differently. See this SO post for more help articles.