I can't seem to work this out. I want to display a list that starts with a specific position in an arraycollection, without changing the array. The goal is to have a set of full screen images that the user can swipe through (like in an ebook), and for the chapter index i want to start with a specific indexnumber in the arraycollection.
Is there a simple way to tell the Itemrenderer to start at a specific indexnumber in the arraycollection.
My code that starts at index 0:
<s:List id="pagedList"
width="100%" height="100%"
verticalScrollPolicy="off" horizontalScrollPolicy="on"
pageScrollingEnabled="true">
<s:layout>
<s:TileLayout orientation="rows" requestedRowCount="1"
columnWidth="{pagedList.width}" rowHeight="{pagedList.height}"
verticalGap="0" horizontalGap="0"/>
</s:layout>
<s:ArrayCollection id="contentData">
<s:Image source="assets/cover.jpg"/>
<s:Image source="assets/introduction.jpg"/>
<s:Image source="assets/H1/40_days.jpg"/>
</s:ArrayCollection>
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer>
<s:Group>
<s:Image source="{data.source}" horizontalAlign="center"/>
</s:Group>
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
AFAIK there is no way to do this. You'll have to sort the dataprovider so that it matches the order in which you want to display the items.
If you don't want to modify the original collection, you can create a ListCollectionView, pass in the original collection to the constructor and add a sort to the ListCollectionView. You can then assign the collection view as the dataprovider of your list.
It all starts with your data. The data itself will need to contain info about a chapter offset. Typically you will store a collection of the offset seek points.
For example:
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Chapters: 1 2 3 4 5
A chapter object will hold a reference to which page to start from and its total length. A set of seek buttons will iterate through a chapter collection, telling your list to start from the appropriate offset (ie chapter 2, starts on index 4 and is 4 items long).
Your page objects can either be a single image, or a collection of images per page. In either case, what you're really building from a data point of view is a hierarchical collection.
if your goal is to show a particular image first why not set the selectedIndex for the List itself. I mean give u'r dataobjects in the dataprovider some id and pass on the index to the list.
hope this help, let me know if this is not what is intended
Might the ensureIndexIsVisible method on the Spark List work?
Note: You may need to click the "Products" checkbox at the top of the following html page to actually see this method.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/List.html#ensureIndexIsVisible()
Related
I have a page in gatsbyjs.
and 10 posts on it.
I would like 1 to have the first kind of styling, posts from 2 to 6, the second kind of styling and the other 3 kind.
It seems to me that in order to style the appearance of posts, I need to grab an array of which these posts are iterated.
Can anyone tell me how to catch her?
I would like them to look like in the picture.
1 biggest 2 next in a smaller diva
my idea is that array [0] is the style for the largest diva for array 1 and array [2] smaller box.
Is it good idea ? and how to get the number of the table thanks to which class I will be styling?
Start with a single sorted array with all of your blog posts.
Create three smaller arrays with Array.slice with the correct amount of posts in each one.
Create three different post components, each one with its unique styling.
Create the main grid divisions in your main component with flexbox or other, and iterate over each of the three arrays, rendering one of the three post components with a unique key.
Grid doesn't fit because I need WindowScroller and they doesn't work together.
I already have 3 nodes in row for dir
but I need to have 6 nodes in row for file
dir and file can't be in the same row, instead must be whitespace (check out screen shots)
I've tried to switch 3 or 6 nodesInRow with isDir flag and track actual nodes indexed as increment after each of actual put-node-in-row but it didn't work because of reRenders that start's not from rowInd = 0
actual:
https://imgbbb.com/images/2019/04/10/Screen-Shot-2019-04-10-at-5.57.30-PMa278117232cc829d.png
expected:
https://imgbbb.com/images/2019/04/11/Screen-Shot-2019-04-11-at-1.19.57-PM.png
P.S. Sorry for direct img links ... it's because of 'You need at least 10 reputation to post images.'
This is the way how I wanted it to work
https://codesandbox.io/s/lpvn23vz7
Setup:
Consider the situation of a multilingual site built with Symfony 3, using YAML files for translation messages and TWIG templates for display.
In one section of content, in English, there should be an instruction showing 3 items each representing a step of a process. In German there should only be 2, while in Spanish there are 50.
The setup for this may be for example:
#messages.en.yaml
root_node:
-
title: English title 1
item: Some first list item
-
title: English title 2
item: Some second list item
-
title: English title 3
item: Some third list item
#messages.de.yaml
root_node:
-
title: German title 1
item: Some other first list item
-
title: German title 2
item: Some second German list item
#messages.es.yaml
root_node:
-
title: Spanish title 1
item: Some Spanish first list item
...
etc ...
Considering this structure, ideally, I would like the template to read the fact that root_node is an array, get it's length so that we can display the total number of steps, then create a structure in the twig template that loops over the array and outputs the steps as some translated title and item text.
Attempting to read the array length by {{'root_node'|length}} and {{('root_node'|trans)|length}} just give the length of the text though and {{root_node|length}} gives an error as the variable is not in the scope of the template, because it should be looked up through the translation service.
Question:
How can I read the length of the array at this translation key?
Should this even be attempted in this manner? If not, is there a best practice for translating arrays of unknown size (dependent on translation language) in Symfony?
There is no direct ability to achieve such behavior into Symfony translator. However it can be achieved indirectly by using pluralization mechanism in Symfony.
You can set custom pluralization logic by using PluralizationRules::set method and then call Translator::transChoice with passing step number as argument for choice. You will need to use transchoice(index) filter into your template to obtain required step.
You can obtain list of steps for particular locale by counting them separately from translation catalogue and passing to template. Alternatively, depending on your application's logic, you can simply obtain translated message for current step and test if it is empty string or not.
I am testing a website form using clj-webdriver. I want to know how to use (input-text) function if the form fields have same class.
From the (input-text) definition it gives "Type the string s into the first form element found with query q". Since every field has same class and when I give,
(input-text ".class")
It only fills the first field. Is there any way to differentiate all fields with the same class?
The fields of the form has only class and type as selectors.
Thank you
input-text only fills the first match.
Use quick-fill to fill them all.
E.g.,:
(quick-fill {".class" "s"})
/edit
You say "for 2 fields of same class I have to enter 2 and 3 as values. and also if the class is "object object-done" can I consider class as ".object". I am not exactly sure what you mean with the latter, but what I understand is that you want to add different values to different elements.
If you want to find specific elements you can use find-elements. These will return a collection of elements:
(find-elements {:class ".class"})
This will find all elements with the class ".class" in order which they appear on the page.
If the collection is stored in a variable text can be added to every element via input-text based on index. So for example if you want to add an increasing index to them you can use map-indexed to add the index of every value to the element as follows (doall is called to walk every element in the lazy sequence - function calls are only made when the elements are accessed and doall makes that happen):
(defn fill!
"Fills all elements with class class with increasing numbers."
[class]
(let [elements (find-elements {:class class})]
(doall
(map-indexed (fn [index element]
(input-text element (str index)))
elements))))
This function is called like (fill! ".class").
Hope this helps.
You should use the (find-elements [webelement by]) function, which returns a list of 'webelementsmatching a givenby`.
From the project documentation, that can be found at https://github.com/semperos/clj-webdriver/wiki/Introduction%3A-Taxi , an example is:
(defn css-finder
"Given a CSS query `q`, return a lazy seq of the elements found by calling `find-elements` with `by-css`. If `q` is an `Element`, it is returned unchanged."
[q]
(if (element? q)
q
(core/find-elements *driver* {:css q})))
I want to display count of no of items fetched per page using pagination like
Displaying 10 items
Although limit is set to pagination to 20 but It will not always fetch 20 items when there are only 15 items or 10 items or 25 items.
In these cases it will either have one page result for items count 15 and 10 or two pages result for items count 25.
I want to print the no of items showing on each page. Like for total items 25.
It will show Displaying 20 items on first page and Displaying 5 items on second page.
How is it possible in CakePHP 3.2 ?
This is how I get it working in CakePHP 3.2
There are two ways you can do it.
Using Helpers
create a file paginator-counter.php in /config directory with your tokens and string and add a line in /src/view/AppView.php
public function initialize()
{
$this->loadHelper('Paginator', ['templates' => 'paginator-counter']);
}
This will load the file located at config/paginator-templates.php
And then use it in your view.
For more : http://book.cakephp.org/3.0/en/views/helpers/paginator.html
Using direct string
Just print in view where you want to print the counter
<?= $this->Paginator->counter('Showing {{current}} results out of {{count}}') ?>
More tokens can be found Here : http://book.cakephp.org/3.0/en/views/helpers/paginator.html#creating-a-page-counter
I'm using 2nd way to print counter ie., using sting directly