0:08
everyone in this video we are going to
0:10
see how to achieve conditional selection
0:14
of rows in Salesforce lightning web
0:16
component lightning data table for
0:19
example here I will be able to
0:23
select account records which are
0:27
of type like other channel partner or
0:31
reseller like that I will be able to
0:33
select but I won't be able to select
0:36
accounts of type Prospect for example
0:39
here I'm able to select this account
0:42
because the type is other if I select
0:46
account it will throw me an error saying
0:49
that please select non Prospect accounts
0:52
only so if you have a requirement where
0:54
you wanted to avoid uh users selecting
1:00
specific rows from Salesforce lightning
1:02
web component lightning data
1:06
table then we can make use of a
1:10
validation like this and then we can
1:12
throw them in error we won't be able to
1:16
checkboxes uh because we don't have any
1:19
attributes where we can set it to true
1:26
it in my Apex class I'm getting top 10
1:32
records in my lightning web component
1:34
I'm using lightning data table this is
1:37
going to be my account records these are
1:39
all the columns that will be displayed
1:41
in the lightning data table whenever I
1:43
select it will call this handle selected
1:47
JavaScript method in selected rows I'm
1:50
using selected account
1:55
IDs so using wire framework I'm fetching
2:03
selected I'm I'm making use of uh the
2:07
selected rows event. detail. selected
2:10
rows and then I'm using map and then I'm
2:13
uh iterating each and every record if it
2:16
is not equal to prospect then it will
2:18
add it to the it will return the temp
2:21
account ID which is the uh account
2:24
record ID which was selected and then it
2:27
will be added to this selected account
2:29
IDs if it is of type Prospect it will
2:31
throw the error even if
2:36
you use select all it will select only
2:39
non Prospect accounts and then it will
2:41
throw and throw that particular
2:46
error so using this simple validation we
2:49
will be able to achieve here I'm
2:52
filtering all the records from the
2:54
selected rows and then I'm assigning it
2:56
to a variable called selected accounts
2:58
here it is filtering uh Records other
3:01
than Prospect if I select a prospect it
3:05
will add it to the even. detail selected
3:08
row but in order to get only the non
3:11
Prospect accounts I'm using this
3:13
variable assignment and then I'm
3:14
filtering and then I'm getting only the
3:23
records please check the video
3:25
description in the video description I
3:27
have given my blog post from the block
3:29
post you should be able to get this
3:31
sample Apex class and as well as the
3:34
lightning web component code for your
3:42
reference I hope it was
3:47
helpful thank you for watching