-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathAccountsDemo.cls
102 lines (85 loc) · 3.44 KB
/
AccountsDemo.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**
* Example data provider for the Grid component.
*/
public with sharing class AccountsDemo extends SObjectGridData {
// ---------------------------------------------
// ---- CONTROLLING OUR QUERY ------------------
// ---------------------------------------------
/*
* The name of our database table.
*/
public override String getObjectName() {
return 'Account';
}
/*
* Fields we want from our database table.
*/
public override Set<String> getSelectFields() {
return new Set<String>{'Name', 'Type', 'BillingStreet', 'BillingCity', 'BillingState', 'BillingPostalCode', 'BillingCountry', 'Phone', 'AccountNumber', 'Industry', 'AnnualRevenue', 'NumberOfEmployees', 'Description', 'Id', 'LastModifiedDate', 'CreatedDate', 'AccountSource'};
}
/*
* This method gives us an opportunity to hand build a where clause for an unusual column, for example
* if we had a boolean column type we wouldn't want to use the quotes like we have here.
*/
public override String buildFilterClause(String column, String value) {
if('<blank>'.equals(value))
return column + ' = \'\'';
return super.buildFilterClause(column, value);
}
/*
* Our default ordering.
*/
public override String getDefaultOrderByClause() {
return 'Name ASC';
}
// ---------------------------------------------
// ---- CONTROLLING FRONTEND RECORD SHAPE ------
// ---------------------------------------------
/*
* This method gives us an opportunity to have different names for fields that we exchange with the frontend
* than we do in our database. For our simple example, we will keep the database field names.
*/
public override String columnNameToDatabaseField(String columnName) {
return columnName;
}
/*
* This method gives us an opportunity to modify the structure or field names of the record we actually
* send to the frontend. Useful if we want to flatten relationship queries, drop __c, etc. For this simple
* demo, we will send the unchanged SObject to the frontend.
*/
public override Object transform(SObject record) {
return record;
}
// ---------------------------------------------
// ---- CONTROLLING FILTERING ------------------
// ---------------------------------------------
/*
* List the column names that we would like to offer filtering on. These names should match the frontend field
* names you have chosen, in case you decide to have different names for frontend and database.
*/
public override List<String> getFilterableColumnNames() {
return new List<String> {'Type', 'Industry'};
}
/*
* Utility method to help us build nice looking filter options to show to users.
*/
public override GridContext.FilterOption getFilterOption(String columnName, String columnValue, String currentSelection, Integer count) {
if(String.isBlank(columnValue))
columnValue = '<blank>';
return new GridContext.FilterOption(
columnValue,
columnValue + ' (' + count + ')',
columnValue.equalsIgnoreCase(currentSelection)
);
}
// ---------------------------------------------
// ---- CONTROLLING SEARCHING ------------------
// ---------------------------------------------
/*
* List the column names that we would like to offer searching on. These names should match the frontend field
* names you have chosen, in case you decide to have different names for frontend and database.
*/
public override List<String> getSearchableColumnNames() {
return new List<String> {'Name', 'AccountNumber', 'Type', 'Industry'};
}
}