You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/collectionview/README.md
+58-39Lines changed: 58 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,11 +7,13 @@
7
7
A NativeScript CollectionView widget. The CollectionView displays data in separate cells, each cell representing one data item. For iOS wraps up [UICollectionView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICollectionView_class/) and for Android wraps up [RecyclerView](https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html). This can be used as an Open Source alternative to [RadListView](https://docs.nativescript.org/ui/components/radlistview/overview).
This command automatically installs the necessary files, as well as stores @nativescript-community/ui-collectionview as a dependency in your project's package.json file.
| ios |[UICollectionView](https://tinyurl.com/y4ugbfgc)| Gets the native iOS view that represents the user interface for this component. Valid only when running on iOS. |
58
-
| android |[android.support.v7.widget.RecyclerView](https://tinyurl.com/lvqebpq)| Gets the native android widget that represents the user interface for this component. Valid only when running on Android OS. |
59
-
| items |`array` or `ItemsSource`| Gets or sets the items collection of the CollectionView. The items property can be set to an array or an object defining length and getItem(index) method. |
60
-
| itemTemplate |`string`| Gets or sets the item template of the CollectionView. |
61
-
| rowHeight |`PercentLength`| Gets or sets the height for every row in the CollectionView. |
62
-
| colWidth |`PercentLength`| Gets or sets the width for every column in the CollectionView. |
| ios |[UICollectionView](https://tinyurl.com/y4ugbfgc)| Gets the native iOS view that represents the user interface for this component. Valid only when running on iOS. |
60
+
| android |[android.support.v7.widget.RecyclerView](https://tinyurl.com/lvqebpq)| Gets the native android widget that represents the user interface for this component. Valid only when running on Android OS. |
61
+
| items |`array` or `ItemsSource`| Gets or sets the items collection of the CollectionView. The items property can be set to an array or an object defining length and getItem(index) method. |
62
+
| itemTemplate |`string`| Gets or sets the item template of the CollectionView. |
63
+
| rowHeight |`PercentLength`| Gets or sets the height for every row in the CollectionView. |
64
+
| colWidth |`PercentLength`| Gets or sets the width for every column in the CollectionView. |
65
+
| spanSize |`Function`| Function to return the span of a cell. For example with `colWidth:50%` a cell with a spanSize of 2 will be `100%` in width |
66
+
| orientation | `'horizontal' | 'vertical'` | Set the orientation for the collectionView |
@@ -69,6 +81,7 @@ There is no additional configuration needed!
69
81
| scrollToIndex(index: number, animated: boolean = true) |`void`| Scrolls the CollectionView to the item with the given index. This can be either animated or not. Defaults to animated. |
70
82
71
83
## Usage
84
+
72
85
You need to add `xmlns:gv="@nativescript-community/ui-collectionview"` to your page tag, and then simply use `<gv:CollectionView/>` in order to add the widget to your page. Use `<gv:Gridview.itemTemplate/>` to specify the template for each cell:
73
86
74
87
### Simple Example:
@@ -104,9 +117,11 @@ const items = [
104
117
```
105
118
106
119
### Templates Example:
120
+
107
121
You can also have multiple templates the same way you add them in the builtin `ListView` control:
@@ -173,30 +191,32 @@ Add the following to your component HTML.
173
191
```
174
192
175
193
### Templates Example:
194
+
176
195
If you want to use multiple item templates, you can do that very similarly to how you do it for the builtin `ListView` control. The only difference is that due to current limitations instead of using the `nsTemplateKey` directive you need to use the `cvTemplateKey` directive that comes from the CollectionView. (In a future version, once the framework allows it this will be changed and you will be able to use the same directive for the `CollectionView` as well)
0 commit comments