function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AndegosuAndegosu 

How to get selected values from custom listview

I have a custom listview that I can select Contact records from but how do I get this information in the controller to do forther actions in apex?

I have code that currently looks like this:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"
                access="global"
                controller="ListViewController">
    <!-- call doInit js function on component load to fetch list view details-->
    <aura:handler name="init" value="this" action="{!c.doInit}"/>
    <!-- aura attributes -->
    <aura:attribute name="listViewResult" type="string[]"/>
    <aura:attribute name="objectInfo" type="string" default="Contact"/>
    <aura:attribute name="currentListViewName" type="string" />
    <aura:attribute name="bShowListView" type="boolean" default="false"/>
    <aura:attribute name="selContacts" type="Contact[]"/>

    <!-- custom controls to display inside listview header-->
    <div class="slds-form-element">
        <lightning:layout class="customCls">
        <lightning:select name="select1" onchange="{!c.onPicklistChange}" label=" ">
            <aura:iteration items="{!v.listViewResult}" var="listView">
                <option value="{!listView.developerName}">{!listView.label}</option>
            </aura:iteration>
        </lightning:select>
            <lightning:button label="Avidentifiera" onclick="{!c.unidentify}" variant="brand"/>
        </lightning:layout>
    </div>

    <!-- lightning List View : https://sforce.co/2Q4sebt-->
    <aura:if isTrue="{!v.bShowListView}">
        <lightning:listView objectApiName="{!v.objectInfo}"
                            listName="{!v.currentListViewName}"
                            rows="5"
                            showSearchBar="true"
                            showActionBar="false"
                            enableInlineEdit="true"
                            showRowLevelActions="false"
        />
    </aura:if>
</aura:component>

 
Deepali KulshresthaDeepali Kulshrestha
Hi Andegosu,

Please go through with below code, it may be helpful to you.

Give the aura id like given below line.
<aura:attribute name="selectedValue" type="String" access="PRIVATE"/>

<lightning:select aura:id="objectName" name="select2" label="Value of Selected PickList" value="{!v.selectedValue}" required="true">

Then get the records like below code.

studentSelect : function(component,event,helper) {
    var selectedObjectName = c.find('objectName').get('v.value');
    console.log(selectedObjectName);
}

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
 
AndegosuAndegosu
Hello Deepali, thank you for your answer.
I'm not trying to get values from a select component, it's from a listview. This is component that I want to get selected values from:
<lightning:listView objectApiName="{!v.objectInfo}"
                            listName="{!v.currentListViewName}"
                            rows="5"
                            showSearchBar="true"
                            showActionBar="false"
                            enableInlineEdit="true"
                            showRowLevelActions="false"
        />
User-added image
 
Dylan McSparrenDylan McSparren
I am looking to do something similar, essentially performing an update on the accounts for selected contacts. Have you had any success?
Virendra Kumar 9Virendra Kumar 9
I am also looking for the exact requiremnt, were you able to find the solution to it ? any suggestion will be much appricated