You need to sign in to do that
Don't have an account?
chandresh joshi
i am fail to display the data in rows dynamically
Lightning component
<aura:component controller="SfObjectController" >
<aura:attribute name="records" type="object"/>
<aura:attribute name="fieldname" type="String[]"/>
<aura:attribute name="index" type="Integer[]"/>
<aura:attribute name="allobjects" type="String[]"/>
<aura:attribute name="allfields" type="String[]"/>
<aura:attribute name="allresults" type="String[]"/>
<aura:attribute name="query" type="String"/>
<aura:attribute name="temp" type="Integer" default="0"/>
<aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
<lightning:select aura:id="select" label="Select Object" onchange="{!c.onChangeobject}" required="true">
<option value="">-- None --</option>
<aura:iteration items="{!v.allobjects}" var="obj">
<option value="{!obj}">{!obj}</option>
</aura:iteration>
</lightning:select>
<ui:inputSelect aura:id="selectfield" class="slds-select" multiple="true" label="Select Fields" required="true" change="{!c.onChangefield}" >
<aura:iteration items="{!v.allfields}" var="field">
<option value="{!field}" text="{!field}"></option>
</aura:iteration>
</ui:inputSelect>
Your Query is: <ui:outputText value="{!v.query}"/>
<button type="button" onclick="{!c.showallrecords}">Execute</button>
<!--for multi-select picklist [select2]
<div class="slds-form-element">
<label for="picklist">Fields</label> <br/>
<select aura:id="selectfield" style="width:100%" onchange="{!c.onChangefield}" class="select2Class" multiple="multiple">
<aura:iteration items="{!v.allfields}" var="field">
<option value="{!field}"> {!field} </option>
</aura:iteration>
</select>
</div>-->
<table>
<thead>
<tr >
<aura:iteration items="{!v.fieldname}" var="field">
<th>
{!field}
</th>
</aura:iteration>
</tr>
</thead>
<aura:iteration items="{!v.allresults}" var="val">
<tr>
<!-- <aura:iteration items="{!v.index}" var="ind">
<td>
{!val}
</td>
</aura:iteration> -->
<!--
for(int i =0;i<field.length;i++){
<td>
{!val[i]}
</td>
}
-->
<td>
{!val[0]}
</td>
<td>
{!val[1]}
</td>
<td>
{!val[2]}
</td>
<td>
{!val[3]}
</td>
</tr>
</aura:iteration>
</table>
</aura:component>
JS File
({
doInit : function(component, event, helper) {
console.log("inside init: ");
// Create the action
var action = component.get("c.getObjectName");
console.log("inside init:"+action);
// Add callback behavior for when response is received
action.setCallback(this, function(response) {
var state = response.getState();
console.log(response.getReturnValue());
console.log(response.getReturnValue());
if (state == "SUCCESS") {
component.set("v.allobjects", response.getReturnValue());
}
else {
console.log("Failed with state: " + state);
}
});
// Send action off to be executed
$A.enqueueAction(action);
},
onChangeobject: function(component, event, helper) {
//Do something with the change handler
console.log("inside on changeobject");
var selectedvalue=component.find("select").get("v.value");
console.log("inside onchangeobject:"+selectedvalue);
//debugger;
var action = component.get("c.getFieldName");
action.setParams({ "selectedObject" : selectedvalue });
//console.log(" onchangeIn:"+ selinst);
action.setCallback(this, function(response) {
var state = response.getState();
console.log(response.getReturnValue());
if (state == "SUCCESS") {
component.set("v.allfields", response.getReturnValue());
console.log("inside if state success");
}
else {
console.log("Failed with state: " + state);
}
});
$A.enqueueAction(action);
},
onChangefield : function(component, event, helper) {
//Do something with the change handler
console.log("inside on changefield");
var selectedvaluefield=component.find("selectfield").get("v.value");
var selectedvalue=component.find("select").get("v.value");
var fieldname= [];
fieldname=selectedvaluefield.split(';');
console.log("fieldname after conv:"+fieldname);
component.set("v.fieldname", fieldname);
// var selectedValueoffield=component.find("selectfield").get("v.value");
console.log("inside onchangefield:"+selectedvaluefield);
console.log("inside onchangefield:"+selectedvalue);
var action = component.get("c.getQuery");
action.setParams({
selectedField:selectedvaluefield,
selectedObj: selectedvalue
});
// action.setParams({ "selectedField" : selectedvaluefield });
// action.setParams({ "selectedObj" : selectedvalue });
//console.log(" onchangeIn:"+ selinst);
action.setCallback(this, function(response) {
var state = response.getState();
console.log(response.getReturnValue());
if (state == "SUCCESS") {
component.set("v.query", response.getReturnValue());
}
else {
console.log("Failed with state: " + state);
}
});
$A.enqueueAction(action);
},
showallrecords: function(component, event, helper) {
console.log("showallrecords");
//Do something with the change handler
console.log("showallrecords");
var selectedvaluefield = component.find("selectfield").get("v.value");
var selectedvalueofquery = component.get("v.query");
var fieldname = [];
fieldname = selectedvaluefield.split(';');
console.log("fieldname after conv:"+fieldname);
component.set("v.fieldname", fieldname);
var action = component.get("c.getQueryResults");
action.setParams({ "selectedQuery" : selectedvalueofquery });
action.setCallback(this, function(response) {
var state = response.getState();
if (state == "SUCCESS") {
var obj=response.getReturnValue();
obj = JSON.parse(obj);
var temp;
var completeRecord=[];
for(temp = 0; temp < obj.length; temp++){
console.log(obj);
var record=obj[temp] ;
console.log(record)
console.log(fieldname.length)
var i;
for(i=0;i<fieldname.length;i++){
var field = fieldname[i];
console.log(field);
var recordtemp=JSON.stringify(record);
recordtemp=recordtemp.toLowerCase();
record=JSON.parse(recordtemp);
var tem=[];
tem.push(record)
var recordValue = record[field];
console.log(recordValue);
// console.log(Object.values(recordValue))
if(recordValue==undefined)
recordValue="";
completeRecord.push(recordValue);
/* if(i==fieldname.length-1){
completeRecord.push("</br>");
}*/
}
}
// obj=obj.split(":").join('');
// obj=obj.split("\"\"").join("-");
// typeof obj;
// obj=obj.filter(Boolean);
console.log(completeRecord);
/** var fil=obj.filter(function(el){ return el!==''; });
console.log("fil:"+fil);**/
// obj=JSON.parse(obj);
var p;
var q;
var tem=[];
var tem2=[];
for(q=0;q<(completeRecord.length)/fieldname.length;q++){
for(p=0;p<fieldname.length;p++){
tem.push(completeRecord[(q*fieldname.length)+p]);
// console.log( tem);
//tem = JSON.parse(tem);
}
// tem=JSON.stringify(tem);
tem2.push(tem);
// console.log("INSIDE TEM");
// console.log(tem);
// console.log("tem2 INSIDE");
tem=[];
// component.set("v.allresults", tem);
}
console.log("OUTSIDE TEM2");
// tem2=JSON.stringmasterrecordidify(tem2);
console.log( tem2);
component.set("v.allresults", tem2);
var index=[];
for(p=0;p<fieldname.length;p++){
index.push(p);
}
component.set("v.index", index)
}
else {
console.log("Failed with state: " + state);
}
});
$A.enqueueAction(action);
}
})
Apex
public with sharing class SfObjectController {
@AuraEnabled
public static String selectedObj {get;set;}
@AuraEnabled
public static List<String> getObjectName(){
List<String> objects=new List<String>();
List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();
for(SObjectType sot:gd){
// system.debug('element:'+sot);
objects.add(sot.getDescribe().getName());
objects.sort();
}
for(String ele:objects){
//String obj=ele;
system.debug('element:'+ele);
// objects.add(sot.getDescribe().getName());
// objects.sort();
}
return objects;
}
@AuraEnabled
public static List<String> getFieldName(String selectedObject)
{ system.debug('selectedObject:'+selectedObject);
SfObjectController.selectedObj=selectedObject;
system.debug('selectedObj:'+selectedObj);
Map<String, Schema.SObjectField> objectFields = Schema.getGlobalDescribe().get(selectedObj).getDescribe().fields.getMap();
List<String> strList = new List<String>(objectFields.keySet());
return strList;
}
@AuraEnabled
public static String getQuery(String selectedField , String selectedObj)
{ system.debug('selectedField:'+selectedField);
system.debug('selectedObj:'+selectedObj);
String strforquery='SELECT '+selectedField+' FROM '+selectedObj;
strforquery = strforquery.replace( ';' , ',' );
return strforquery;
}
@AuraEnabled
public static String getQueryResults( String selectedQuery) {
System.debug('strQry'+selectedQuery);
List<sObject> strResults = Database.query(selectedQuery);
return JSON.serialize(strResults);
}
}
<aura:component controller="SfObjectController" >
<aura:attribute name="records" type="object"/>
<aura:attribute name="fieldname" type="String[]"/>
<aura:attribute name="index" type="Integer[]"/>
<aura:attribute name="allobjects" type="String[]"/>
<aura:attribute name="allfields" type="String[]"/>
<aura:attribute name="allresults" type="String[]"/>
<aura:attribute name="query" type="String"/>
<aura:attribute name="temp" type="Integer" default="0"/>
<aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
<lightning:select aura:id="select" label="Select Object" onchange="{!c.onChangeobject}" required="true">
<option value="">-- None --</option>
<aura:iteration items="{!v.allobjects}" var="obj">
<option value="{!obj}">{!obj}</option>
</aura:iteration>
</lightning:select>
<ui:inputSelect aura:id="selectfield" class="slds-select" multiple="true" label="Select Fields" required="true" change="{!c.onChangefield}" >
<aura:iteration items="{!v.allfields}" var="field">
<option value="{!field}" text="{!field}"></option>
</aura:iteration>
</ui:inputSelect>
Your Query is: <ui:outputText value="{!v.query}"/>
<button type="button" onclick="{!c.showallrecords}">Execute</button>
<!--for multi-select picklist [select2]
<div class="slds-form-element">
<label for="picklist">Fields</label> <br/>
<select aura:id="selectfield" style="width:100%" onchange="{!c.onChangefield}" class="select2Class" multiple="multiple">
<aura:iteration items="{!v.allfields}" var="field">
<option value="{!field}"> {!field} </option>
</aura:iteration>
</select>
</div>-->
<table>
<thead>
<tr >
<aura:iteration items="{!v.fieldname}" var="field">
<th>
{!field}
</th>
</aura:iteration>
</tr>
</thead>
<aura:iteration items="{!v.allresults}" var="val">
<tr>
<!-- <aura:iteration items="{!v.index}" var="ind">
<td>
{!val}
</td>
</aura:iteration> -->
<!--
for(int i =0;i<field.length;i++){
<td>
{!val[i]}
</td>
}
-->
<td>
{!val[0]}
</td>
<td>
{!val[1]}
</td>
<td>
{!val[2]}
</td>
<td>
{!val[3]}
</td>
</tr>
</aura:iteration>
</table>
</aura:component>
JS File
({
doInit : function(component, event, helper) {
console.log("inside init: ");
// Create the action
var action = component.get("c.getObjectName");
console.log("inside init:"+action);
// Add callback behavior for when response is received
action.setCallback(this, function(response) {
var state = response.getState();
console.log(response.getReturnValue());
console.log(response.getReturnValue());
if (state == "SUCCESS") {
component.set("v.allobjects", response.getReturnValue());
}
else {
console.log("Failed with state: " + state);
}
});
// Send action off to be executed
$A.enqueueAction(action);
},
onChangeobject: function(component, event, helper) {
//Do something with the change handler
console.log("inside on changeobject");
var selectedvalue=component.find("select").get("v.value");
console.log("inside onchangeobject:"+selectedvalue);
//debugger;
var action = component.get("c.getFieldName");
action.setParams({ "selectedObject" : selectedvalue });
//console.log(" onchangeIn:"+ selinst);
action.setCallback(this, function(response) {
var state = response.getState();
console.log(response.getReturnValue());
if (state == "SUCCESS") {
component.set("v.allfields", response.getReturnValue());
console.log("inside if state success");
}
else {
console.log("Failed with state: " + state);
}
});
$A.enqueueAction(action);
},
onChangefield : function(component, event, helper) {
//Do something with the change handler
console.log("inside on changefield");
var selectedvaluefield=component.find("selectfield").get("v.value");
var selectedvalue=component.find("select").get("v.value");
var fieldname= [];
fieldname=selectedvaluefield.split(';');
console.log("fieldname after conv:"+fieldname);
component.set("v.fieldname", fieldname);
// var selectedValueoffield=component.find("selectfield").get("v.value");
console.log("inside onchangefield:"+selectedvaluefield);
console.log("inside onchangefield:"+selectedvalue);
var action = component.get("c.getQuery");
action.setParams({
selectedField:selectedvaluefield,
selectedObj: selectedvalue
});
// action.setParams({ "selectedField" : selectedvaluefield });
// action.setParams({ "selectedObj" : selectedvalue });
//console.log(" onchangeIn:"+ selinst);
action.setCallback(this, function(response) {
var state = response.getState();
console.log(response.getReturnValue());
if (state == "SUCCESS") {
component.set("v.query", response.getReturnValue());
}
else {
console.log("Failed with state: " + state);
}
});
$A.enqueueAction(action);
},
showallrecords: function(component, event, helper) {
console.log("showallrecords");
//Do something with the change handler
console.log("showallrecords");
var selectedvaluefield = component.find("selectfield").get("v.value");
var selectedvalueofquery = component.get("v.query");
var fieldname = [];
fieldname = selectedvaluefield.split(';');
console.log("fieldname after conv:"+fieldname);
component.set("v.fieldname", fieldname);
var action = component.get("c.getQueryResults");
action.setParams({ "selectedQuery" : selectedvalueofquery });
action.setCallback(this, function(response) {
var state = response.getState();
if (state == "SUCCESS") {
var obj=response.getReturnValue();
obj = JSON.parse(obj);
var temp;
var completeRecord=[];
for(temp = 0; temp < obj.length; temp++){
console.log(obj);
var record=obj[temp] ;
console.log(record)
console.log(fieldname.length)
var i;
for(i=0;i<fieldname.length;i++){
var field = fieldname[i];
console.log(field);
var recordtemp=JSON.stringify(record);
recordtemp=recordtemp.toLowerCase();
record=JSON.parse(recordtemp);
var tem=[];
tem.push(record)
var recordValue = record[field];
console.log(recordValue);
// console.log(Object.values(recordValue))
if(recordValue==undefined)
recordValue="";
completeRecord.push(recordValue);
/* if(i==fieldname.length-1){
completeRecord.push("</br>");
}*/
}
}
// obj=obj.split(":").join('');
// obj=obj.split("\"\"").join("-");
// typeof obj;
// obj=obj.filter(Boolean);
console.log(completeRecord);
/** var fil=obj.filter(function(el){ return el!==''; });
console.log("fil:"+fil);**/
// obj=JSON.parse(obj);
var p;
var q;
var tem=[];
var tem2=[];
for(q=0;q<(completeRecord.length)/fieldname.length;q++){
for(p=0;p<fieldname.length;p++){
tem.push(completeRecord[(q*fieldname.length)+p]);
// console.log( tem);
//tem = JSON.parse(tem);
}
// tem=JSON.stringify(tem);
tem2.push(tem);
// console.log("INSIDE TEM");
// console.log(tem);
// console.log("tem2 INSIDE");
tem=[];
// component.set("v.allresults", tem);
}
console.log("OUTSIDE TEM2");
// tem2=JSON.stringmasterrecordidify(tem2);
console.log( tem2);
component.set("v.allresults", tem2);
var index=[];
for(p=0;p<fieldname.length;p++){
index.push(p);
}
component.set("v.index", index)
}
else {
console.log("Failed with state: " + state);
}
});
$A.enqueueAction(action);
}
})
Apex
public with sharing class SfObjectController {
@AuraEnabled
public static String selectedObj {get;set;}
@AuraEnabled
public static List<String> getObjectName(){
List<String> objects=new List<String>();
List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();
for(SObjectType sot:gd){
// system.debug('element:'+sot);
objects.add(sot.getDescribe().getName());
objects.sort();
}
for(String ele:objects){
//String obj=ele;
system.debug('element:'+ele);
// objects.add(sot.getDescribe().getName());
// objects.sort();
}
return objects;
}
@AuraEnabled
public static List<String> getFieldName(String selectedObject)
{ system.debug('selectedObject:'+selectedObject);
SfObjectController.selectedObj=selectedObject;
system.debug('selectedObj:'+selectedObj);
Map<String, Schema.SObjectField> objectFields = Schema.getGlobalDescribe().get(selectedObj).getDescribe().fields.getMap();
List<String> strList = new List<String>(objectFields.keySet());
return strList;
}
@AuraEnabled
public static String getQuery(String selectedField , String selectedObj)
{ system.debug('selectedField:'+selectedField);
system.debug('selectedObj:'+selectedObj);
String strforquery='SELECT '+selectedField+' FROM '+selectedObj;
strforquery = strforquery.replace( ';' , ',' );
return strforquery;
}
@AuraEnabled
public static String getQueryResults( String selectedQuery) {
System.debug('strQry'+selectedQuery);
List<sObject> strResults = Database.query(selectedQuery);
return JSON.serialize(strResults);
}
}
zubair ahmed 20
you can here for more valuable and detailed information. zong internet packages (https://www.mobilepackages.co/p/zong-internet-packages.html) and carpet cleaner (https://bestcarpetcleaner.org/best-carpet-cleaner-on-a-budget/)
khan g
Zong Call Packages (https://www.mobilepackages.co/p/zong-call-packages.html) keep you update about Zong Call Packages and Zong SMS packages. (https://www.mobilepackages.co/p/zong-sms-package.html)