Skip to content

Commit a8c597f

Browse files
chore(ListView):
-Add documentation code snippet tags -Rename example files to better match the example code -Remove left over unused functions
1 parent c9bcfdc commit a8c597f

File tree

11 files changed

+22
-23
lines changed

11 files changed

+22
-23
lines changed

sdk/app/listview/filtering/filtering-model.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// >> listview-grouping-model
1+
// >> listview-filtering-model
22
import { ObservableArray } from "tns-core-modules/data/observable-array";
33
import * as timer from "tns-core-modules/timer";
44
import { Observable } from"tns-core-modules/data/observable";
@@ -26,11 +26,13 @@ export class ViewModel extends Observable {
2626
return this.get("_items");
2727
}
2828

29-
get myFilteringFunc(): (item: any) => any {
29+
// >> listview-filtering-func
30+
get myFilteringFunc(): (item: any) => boolean {
3031
return (item: DataItem) => {
3132
return item.itemName.includes("Special Item");
3233
};
3334
}
35+
// << listview-filtering-func
3436

3537
private getRandomLengthString() {
3638
var sentenceLength = Math.round((Math.random() * 15));
@@ -72,4 +74,4 @@ var items: DataItem[] = [
7274
new DataItem(80, "Item 80", "This is item category is: Category 1", "Category 1"),
7375
new DataItem(54, "Item 54", "This is item category is: Category 3", "Category 3"),
7476
];
75-
// << listview-grouping-model
77+
// << listview-filtering-model
File renamed without changes.
File renamed without changes.

sdk/app/listview/grouping/grouping-model.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,13 @@ export class ViewModel extends Observable {
2626
this.set("_isEnabled", value);
2727
}
2828

29+
// >> listview-grouping-func
2930
get myGroupingFunc(): (item: any) => any {
3031
return (item: DataItem) => {
3132
return item.category;
3233
};
3334
}
34-
35-
get myFilteringFunc(): (item: any) => any {
36-
return (item: DataItem) => {
37-
return item.itemName.includes("Special Item");
38-
};
39-
}
40-
41-
get mySortingFunc(): (item: any, otherItem: any) => number {
42-
return (item: DataItem, otherItem: DataItem) => {
43-
var res = item.id < otherItem.id ? -1 : item.id > otherItem.id ? 1 : 0;
44-
return res;
45-
};
46-
}
35+
// << listview-grouping-func
4736

4837
private getRandomLengthString() {
4938
var sentenceLength = Math.round((Math.random() * 15));

sdk/app/listview/multiple-data-operations/getting-started-page.ts renamed to sdk/app/listview/multiple-data-operations/multiple-data-operations-page.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// >> listview-multiple-operations-code
12
import { ViewModel } from "./multiple-model";
23
import { Page } from "tns-core-modules/ui/page";
34
import { RadListView } from "nativescript-pro-ui/listview";
@@ -42,4 +43,5 @@ export function toggleGrouping() {
4243
listView.groupingFunction = undefined;
4344
bindingContext.isGroupingEnabled = false;
4445
}
45-
}
46+
}
47+
// << listview-multiple-operations-code

sdk/app/listview/multiple-data-operations/getting-started-page.xml renamed to sdk/app/listview/multiple-data-operations/multiple-data-operations-page.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<navigation:ExamplePage xmlns:navigation="navigation/example-page" loaded="onPageLoaded" xmlns:lv="nativescript-pro-ui/listview" xmlns="http://www.nativescript.org/tns.xsd">
2+
<!-- >> listview-multiple-data-operations-xml -->
23
<GridLayout rows="*, 7*">
34
<StackLayout orientation="horizontal">
45
<Button width="33%" text="{{isFilteringEnabled ? 'Disable filtering' : 'Enable filtering'}}" tap="toggleFilter"/>
@@ -17,4 +18,5 @@
1718
</lv:RadListView.itemTemplate>
1819
</lv:RadListView>
1920
</GridLayout>
21+
<!-- << listview-multiple-data-operations-xml -->
2022
</navigation:ExamplePage>

sdk/app/listview/multiple-data-operations/multiple-model.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// >> listview-multiple-operations-model
12
import { ObservableArray } from "tns-core-modules/data/observable-array";
23
import * as timer from "tns-core-modules/timer";
34
import { Observable } from"tns-core-modules/data/observable";
@@ -101,4 +102,5 @@ var items: DataItem[] = [
101102
new DataItem(345, "Item 345", "This is item category is: Category 1", "Category 1"),
102103
new DataItem(80, "Item 80", "This is item category is: Category 1", "Category 1"),
103104
new DataItem(54, "Item 54", "This is item category is: Category 3", "Category 3"),
104-
];
105+
];
106+
// << listview-multiple-operations-model

sdk/app/listview/sorting/sorting-model.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// >> listview-grouping-model
1+
// >> listview-sorting-model
22
import { ObservableArray } from "tns-core-modules/data/observable-array";
33
import * as timer from "tns-core-modules/timer";
44
import { Observable } from"tns-core-modules/data/observable";
@@ -26,12 +26,14 @@ export class ViewModel extends Observable {
2626
return this.get("_items");
2727
}
2828

29+
// >> listview-sorting-func
2930
get mySortingFunc(): (item: any, otherItem: any) => number {
3031
return (item: DataItem, otherItem: DataItem) => {
3132
var res = item.id < otherItem.id ? -1 : item.id > otherItem.id ? 1 : 0;
3233
return res;
3334
};
3435
}
36+
// << listview-sorting-func
3537

3638
private getRandomLengthString() {
3739
var sentenceLength = Math.round((Math.random() * 15));
@@ -73,4 +75,4 @@ var items: DataItem[] = [
7375
new DataItem(80, "Item 80", "This is item category is: Category 1", "Category 1"),
7476
new DataItem(54, "Item 54", "This is item category is: Category 3", "Category 3"),
7577
];
76-
// << listview-grouping-model
78+
// << listview-sorting-model
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)