Skip to content

Commit a5f4a21

Browse files
committed
add documentation #11
1 parent 61c86dd commit a5f4a21

File tree

1 file changed

+54
-10
lines changed

1 file changed

+54
-10
lines changed

README.md

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
This is generic lighting data table , which is build in lwc.
1010
The customization are done by design attributes.
1111

12-
Features
12+
Main features
1313
The data table has following features.
1414
- Show records for both custom and standard object.
1515
- Add cols as per the fields exist in object in JSON format.
1616
- Pagination as First,Previous,Next,Last buttons.
1717
- New record creation action
1818
- Row action, like : show detail, edit record, delete record
19+
- configurable buttons (for developers, see "Buttons configuration")
1920

2021
## Steps to Customization through Design Attribute
2122

@@ -24,15 +25,15 @@ Only specify the icon name if you wish to override the default icon of the objec
2425
<br/><br/>
2526
Design Attribute
2627

27-
| Label | Type | Value | Example |
28-
|-----------------|------------|------------------------------|---------------------|
29-
| Enter Icon Name | String | provide slds icon name | `standard:account` |
30-
| Enter Title | String | provide table title | LWC Table |
31-
| Enter Object API Name | String| provide object custom or standard API name| Account |
32-
| Enter Columns JSON | String | { `fieldName`:api name,`label`:col label,`type`:text,number,date }. **Note** : for related field it should be concat with . i.e : Account.Name for contact | See below **Column JSON Example**
33-
Enter Related field API Name| String | Enter related field api name | Example AccountId for contact when component is on account layout.
34-
Enter WHERE clause | String | provide aditional filters | Example `LastName like '%s' AND Account.Name like '%t'`
35-
| Show the number of record | Boolean | append the number of records in the title | checked(true) OR not checked(false) |
28+
| Label | Required | Type | Value | Example |
29+
|-----------------|------------|------------|------------------------------|---------------------|
30+
| Enter Icon Name | false | String | provide slds icon name | `standard:account` |
31+
| Enter Title | true | String | provide table title | LWC Table |
32+
| Enter Object API Name | true | String| provide object custom or standard API name| Account |
33+
| Enter Columns JSON | true | String | { `fieldName`:api name,`label`:col label,`type`:text,number,date }. **Note** : for related field it should be concat with . i.e : Account.Name for contact | See below **Column JSON Example**
34+
Enter Related field API Name | false | String | Enter related field api name | Example AccountId for contact when component is on account layout.
35+
Enter WHERE clause | false | String | provide aditional filters | Example `LastName like '%s' AND Account.Name like '%t'`
36+
| Show the number of record | false | Boolean | append the number of records in the title | checked(true) OR not checked(false) |
3637

3738
## Columns JSON Example
3839
``` yaml
@@ -58,6 +59,49 @@ Enter WHERE clause | String | provide aditional filters | Example `LastName like
5859
"type": "text"
5960
}]
6061
```
62+
## Buttons configuration (for developers, accessible in the component and from parent component)
63+
64+
### Call apex or javascript method
65+
callApexFromButton must be true
66+
67+
### Fire event to parent component
68+
- callApex must be false
69+
- needSelectedRows can be true if you need to send selected rows to parent component
70+
71+
### Example
72+
JSON :
73+
```
74+
[
75+
{ label : "delete all", variant: "destructive", needSelectedRows: true, callApex: true },
76+
{ label : "action button", variant : "brand", needSelectedRows: false, callApex: false },
77+
{ label : "another action button", variant : "brand", needSelectedRows: true, callApex: false }
78+
];
79+
```
80+
Parent component (**you don't need parent component, you can define default buttons using actionButtonsList**) :
81+
```
82+
//in template
83+
<c-lwc-related-list object-name="Contact"
84+
columns={columns}
85+
related-field-api="AccountId"
86+
is-counter-displayed=true
87+
action-buttons-list={actions}
88+
show-checkboxes=true
89+
onaction2={helloWorld}
90+
onaction3={helloWorld}
91+
92+
//in js controller
93+
helloWorld(event) {
94+
console.log('hello world');
95+
console.log('event rows ', event.detail);
96+
}
97+
```
98+
99+
The first button "delete all" is not going to send event to parent it will call the javascript method callApexFromButton you must
100+
implement the desired javascript/apex call based on the button label.
101+
102+
The button "action button" fires the event action2
103+
The button "another action button" fires the event action3
104+
61105
## Deploy
62106
Click Button to deploy source in Developer/Sandbox
63107

0 commit comments

Comments
 (0)