You need to sign in to do that
Don't have an account?
edukondalu thodeti
how to hide the fields of the object when click on the object name in lightning
i had displayed all the objectnames in an org and the fields of that object when click on the objectname by using the below code
apex controller public class objfield{ @AuraEnabled public static List<string> getAllObjects(){ List<string> SObjectList = new List<string>(); for(Schema.SObjectType objTyp : Schema.getGlobalDescribe().Values()){ String name = objTyp.getDescribe().getName(); // Exclude all the unwanted Sobjects e.g. History, Share etc.. if(!name.containsignorecase('history') && !name.containsignorecase('tag')&& !name.containsignorecase('share') && !name.containsignorecase('feed')){ SobjectList.add(name); System.debug( 'Name : ' + name); } } return SObjectList; } @AuraEnabled public static List<String> getAllFields(String fld){ List<String> fieldList = new List<String>(); Map<String,Schema.SObjectType> gd = Schema.getGlobalDescribe(); Schema.SObjectType sobjType = gd.get(fld); Schema.DescribeSObjectResult describeResult = sobjType.getDescribe(); Map<String,Schema.SObjectField> fieldsMap = describeResult.fields.getMap(); for(string str: fieldsMap.keySet()){ fieldList.add(fieldsMap.get(str).getDescribe().getLabel()); } return fieldList; } } component1 <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" controller="objfield"> <aura:attribute name="objList" type="List" /> <aura:handler name="init" value="{!this}" action="{!c.doinit}"/> <aura:if isTrue="{!v.objList.length > 0}"> <table class="slds-table slds-table_bordered slds-table_cell-buffer"> <thead> <tr class="slds-text-title_caps"> <th scope="col"> <div class="slds-truncate" title="Objects">List Of Objects</div> </th> </tr> </thead> <tbody> <aura:iteration items="{!v.objList}" var="a"> <tr> <td> <c:objectSelection objName="{!a}" /> </td> </tr> </aura:iteration> </tbody> </table> </aura:if> </aura:component> component2 <!-- objectSelection --> <aura:component controller="objfield"> <aura:attribute name="objName" type="String" /> <aura:attribute name="fieldsList" type="List" /> <lightning:button variant="base" label="{!v.objName}" onclick="{!c.handleObjName}" ></lightning:button> <aura:if isTrue="{!v.fieldsList.length > 0}"> <aura:iteration items="{!v.fieldsList}" var="a"> <tr> <td> {!a} </td> </tr> </aura:iteration> </aura:if> </aura:component> controller1 ({ doinit : function(component, event, helper) { var action = component.get("c.getAllObjects"); action.setCallback(this,function(response){ var status = response.getState(); if(status === "SUCCESS"){ component.set("v.objList", response.getReturnValue()); } }); $A.enqueueAction(action); }, }) controller2 ({ handleObjName :function(component, event, helper) { console.log(event.getSource().get("v.label")); var action = component.get("c.getAllFields"); action.setParams({"fld": event.getSource().get("v.label")}); action.setCallback(this, function(response) { var state = response.getState(); console.log(response.getReturnValue()); if (state == "SUCCESS") { //alert("fld"+response.getReturnValue()) component.set("v.fieldsList", response.getReturnValue()); } }); $A.enqueueAction(action); }, })i got the result like thesenow my requirement is when ever i click on the objectname the fields of that object to be hide.pls anyone help me i'm new to lightning
https://sfdcpoint.blogspot.com/2020/02/expandcollapsible-complete-table-row-in.html
Regards
Andrew