Skip to main content
Tweeted twitter.com/StackSalesforce/status/1164507620104986631
deleted 41 characters in body
Source Link
Guha Arumugam
  • 113
  • 1
  • 1
  • 8

I couldn't figure out a way to make the first column as hyperlinked. I tried to work around by creating a formula field with HYPERLINK("/" &Id, "View Record"). But it generates this(View RecordRef My Screenshot) on the data table in UI. If anyone can help with some workaround?

I couldn't figure out a way to make the first column as hyperlinked. I tried to work around by creating a formula field with HYPERLINK("/" &Id, "View Record"). But it generates this(View Record) on the data table in UI. If anyone can help with some workaround?

I couldn't figure out a way to make the first column as hyperlinked. I tried to work around by creating a formula field with HYPERLINK("/" &Id, "View Record"). But it generates this(Ref My Screenshot) on the data table in UI. If anyone can help with some workaround?

added 91 characters in body
Source Link
Guha Arumugam
  • 113
  • 1
  • 1
  • 8

enter image description here

enter image description here

Problem: 

I couldn't figure out a way to make the first column as hyperlinked. I tried to work around by creating a formula field with HYPERLINK("/" &Id, "View Record"). But it generates this(View Record) on the data table in UI. If anyone can help with some workaround?

({ init : function(component, event, helper) { helper.getLightningTableData(component); }, updateColumnSorting: function (cmp, event, helper) { var fieldName = event.getParam('fieldName'); var sortDirection = event.getParam('sortDirection'); cmp.set("v.sortedBy", fieldName); cmp.set("v.sortedDirection", sortDirection); helper.sortData(cmp, fieldName, sortDirection); }, getSelectedName: function (component, event) { var selectedRows = event.getParam('selectedRows'); for (var i = 0; i < selectedRows.length; i++){ console.log('>>>',selectedRows[i].Subject); }  } }) 

})

({ getLightningTableData : function(component) { var recLimit = component.get("v.recLimit"); var sColumn = component.get("v.fields"); var sObject = component.get("v.object"); var action = component.get("c.getsObjectRecords"); action.setParams({ ObjectName : sObject, fieldstoget : sColumn, recLimit : recLimit }); action.setCallback(this,function(response){ var state = response.getState(); if(state == 'SUCCESS'){ var rtnValue = response.getReturnValue(); component.set("v.mycolumn",rtnValue.tableColumn); component.set("v.mydata",rtnValue.tableRecord); } }); $A.enqueueAction(action); }, sortData: function (cmp, fieldName, sortDirection) { var data = cmp.get("v.mydata"); var reverse = sortDirection !== 'asc'; data.sort(this.sortBy(fieldName, reverse)) cmp.set("v.mydata", data); }, sortBy: function (field, reverse, primer) { var key = primer ? function(x) {return primer(x[field])} : function(x) {return x[field]}; reverse = !reverse ? 1 : -1; return function (a, b) { return a = key(a), b = key(b), reverse * ((a > b) - (b > a)); }  } }) 

})

public with sharing class lightningTableController { @AuraEnabled public static lightningTableWraper getsObjectRecords(String ObjectName,String fieldstoget,Integer recLimit){ List<String> lstfieldstoget = fieldstoget.split(','); List<lightningTableColumnWrapper> lstTableColumn = new list<lightningTableColumnWrapper> (); DescribeSObjectResult objResult = Schema.getGlobalDescribe().get(ObjectName).getDescribe(); for(String field : lstfieldstoget){ lightningTableColumnWrapper colWrapper = new lightningTableColumnWrapper(); DescribeFieldResult fieldResult = objResult.fields.getMap().get(field).getDescribe(); colWrapper.label = fieldResult.getLabel(); colWrapper.fieldName = fieldResult.getName(); colWrapper.type = String.valueof(fieldResult.getType()).toLowerCase(); colWrapper.sortable = true; lstTableColumn.add(colWrapper); } Id loggedUser = UserInfo.getUserId(); String queryString = 'Select '+ String.escapeSingleQuotes(String.join(lstfieldstoget,','))+ ' from '+ String.escapeSingleQuotes(ObjectName) + ' Limit ' +recLimit; LightningTableWraper ltngTableWrapper = new LightningTableWraper(); ltngTableWrapper.tableRecord = database.query(queryString); ltngTableWrapper.tableColumn = lstTableColumn; return ltngTableWrapper; } public class lightningTableColumnWrapper { @AuraEnabled public string label {get;set;} @AuraEnabled public String fieldName {get;set;} @AuraEnabled public string type {get;set;} @AuraEnabled public boolean sortable {get;set;} } public class lightningTableWraper{ @AuraEnabled public List<sObject> tableRecord {get;Set;} @AuraEnabled public List<lightningTableColumnWrapper> tableColumn {get;set;}  } } 

}

Problem: I couldn't figure out a way to make the first column as hyperlinked. I tried to work around by creating a formula field with HYPERLINK("/" &Id, "View Record"). But it generates this(View Record) on the data table in UI. If anyone can help with some workaround?

({ init : function(component, event, helper) { helper.getLightningTableData(component); }, updateColumnSorting: function (cmp, event, helper) { var fieldName = event.getParam('fieldName'); var sortDirection = event.getParam('sortDirection'); cmp.set("v.sortedBy", fieldName); cmp.set("v.sortedDirection", sortDirection); helper.sortData(cmp, fieldName, sortDirection); }, getSelectedName: function (component, event) { var selectedRows = event.getParam('selectedRows'); for (var i = 0; i < selectedRows.length; i++){ console.log('>>>',selectedRows[i].Subject); } } 

})

({ getLightningTableData : function(component) { var recLimit = component.get("v.recLimit"); var sColumn = component.get("v.fields"); var sObject = component.get("v.object"); var action = component.get("c.getsObjectRecords"); action.setParams({ ObjectName : sObject, fieldstoget : sColumn, recLimit : recLimit }); action.setCallback(this,function(response){ var state = response.getState(); if(state == 'SUCCESS'){ var rtnValue = response.getReturnValue(); component.set("v.mycolumn",rtnValue.tableColumn); component.set("v.mydata",rtnValue.tableRecord); } }); $A.enqueueAction(action); }, sortData: function (cmp, fieldName, sortDirection) { var data = cmp.get("v.mydata"); var reverse = sortDirection !== 'asc'; data.sort(this.sortBy(fieldName, reverse)) cmp.set("v.mydata", data); }, sortBy: function (field, reverse, primer) { var key = primer ? function(x) {return primer(x[field])} : function(x) {return x[field]}; reverse = !reverse ? 1 : -1; return function (a, b) { return a = key(a), b = key(b), reverse * ((a > b) - (b > a)); } } 

})

public with sharing class lightningTableController { @AuraEnabled public static lightningTableWraper getsObjectRecords(String ObjectName,String fieldstoget,Integer recLimit){ List<String> lstfieldstoget = fieldstoget.split(','); List<lightningTableColumnWrapper> lstTableColumn = new list<lightningTableColumnWrapper> (); DescribeSObjectResult objResult = Schema.getGlobalDescribe().get(ObjectName).getDescribe(); for(String field : lstfieldstoget){ lightningTableColumnWrapper colWrapper = new lightningTableColumnWrapper(); DescribeFieldResult fieldResult = objResult.fields.getMap().get(field).getDescribe(); colWrapper.label = fieldResult.getLabel(); colWrapper.fieldName = fieldResult.getName(); colWrapper.type = String.valueof(fieldResult.getType()).toLowerCase(); colWrapper.sortable = true; lstTableColumn.add(colWrapper); } Id loggedUser = UserInfo.getUserId(); String queryString = 'Select '+ String.escapeSingleQuotes(String.join(lstfieldstoget,','))+ ' from '+ String.escapeSingleQuotes(ObjectName) + ' Limit ' +recLimit; LightningTableWraper ltngTableWrapper = new LightningTableWraper(); ltngTableWrapper.tableRecord = database.query(queryString); ltngTableWrapper.tableColumn = lstTableColumn; return ltngTableWrapper; } public class lightningTableColumnWrapper { @AuraEnabled public string label {get;set;} @AuraEnabled public String fieldName {get;set;} @AuraEnabled public string type {get;set;} @AuraEnabled public boolean sortable {get;set;} } public class lightningTableWraper{ @AuraEnabled public List<sObject> tableRecord {get;Set;} @AuraEnabled public List<lightningTableColumnWrapper> tableColumn {get;set;} } 

}

Problem: 

I couldn't figure out a way to make the first column as hyperlinked. I tried to work around by creating a formula field with HYPERLINK("/" &Id, "View Record"). But it generates this(View Record) on the data table in UI. If anyone can help with some workaround?

({ init : function(component, event, helper) { helper.getLightningTableData(component); }, updateColumnSorting: function (cmp, event, helper) { var fieldName = event.getParam('fieldName'); var sortDirection = event.getParam('sortDirection'); cmp.set("v.sortedBy", fieldName); cmp.set("v.sortedDirection", sortDirection); helper.sortData(cmp, fieldName, sortDirection); }, getSelectedName: function (component, event) { var selectedRows = event.getParam('selectedRows'); for (var i = 0; i < selectedRows.length; i++){ console.log('>>>',selectedRows[i].Subject); }  } }) 
({ getLightningTableData : function(component) { var recLimit = component.get("v.recLimit"); var sColumn = component.get("v.fields"); var sObject = component.get("v.object"); var action = component.get("c.getsObjectRecords"); action.setParams({ ObjectName : sObject, fieldstoget : sColumn, recLimit : recLimit }); action.setCallback(this,function(response){ var state = response.getState(); if(state == 'SUCCESS'){ var rtnValue = response.getReturnValue(); component.set("v.mycolumn",rtnValue.tableColumn); component.set("v.mydata",rtnValue.tableRecord); } }); $A.enqueueAction(action); }, sortData: function (cmp, fieldName, sortDirection) { var data = cmp.get("v.mydata"); var reverse = sortDirection !== 'asc'; data.sort(this.sortBy(fieldName, reverse)) cmp.set("v.mydata", data); }, sortBy: function (field, reverse, primer) { var key = primer ? function(x) {return primer(x[field])} : function(x) {return x[field]}; reverse = !reverse ? 1 : -1; return function (a, b) { return a = key(a), b = key(b), reverse * ((a > b) - (b > a)); }  } }) 
public with sharing class lightningTableController { @AuraEnabled public static lightningTableWraper getsObjectRecords(String ObjectName,String fieldstoget,Integer recLimit){ List<String> lstfieldstoget = fieldstoget.split(','); List<lightningTableColumnWrapper> lstTableColumn = new list<lightningTableColumnWrapper> (); DescribeSObjectResult objResult = Schema.getGlobalDescribe().get(ObjectName).getDescribe(); for(String field : lstfieldstoget){ lightningTableColumnWrapper colWrapper = new lightningTableColumnWrapper(); DescribeFieldResult fieldResult = objResult.fields.getMap().get(field).getDescribe(); colWrapper.label = fieldResult.getLabel(); colWrapper.fieldName = fieldResult.getName(); colWrapper.type = String.valueof(fieldResult.getType()).toLowerCase(); colWrapper.sortable = true; lstTableColumn.add(colWrapper); } Id loggedUser = UserInfo.getUserId(); String queryString = 'Select '+ String.escapeSingleQuotes(String.join(lstfieldstoget,','))+ ' from '+ String.escapeSingleQuotes(ObjectName) + ' Limit ' +recLimit; LightningTableWraper ltngTableWrapper = new LightningTableWraper(); ltngTableWrapper.tableRecord = database.query(queryString); ltngTableWrapper.tableColumn = lstTableColumn; return ltngTableWrapper; } public class lightningTableColumnWrapper { @AuraEnabled public string label {get;set;} @AuraEnabled public String fieldName {get;set;} @AuraEnabled public string type {get;set;} @AuraEnabled public boolean sortable {get;set;} } public class lightningTableWraper{ @AuraEnabled public List<sObject> tableRecord {get;Set;} @AuraEnabled public List<lightningTableColumnWrapper> tableColumn {get;set;}  } } 
Source Link
Guha Arumugam
  • 113
  • 1
  • 1
  • 8
Loading