You need to sign in to do that
Don't have an account?
Seraph
Help Removing Rows with Pageblock Column data "none"
I have a visualforce page(page 2) that displays results from another visualforce page(page 1)(values in the selectlist are from the inputs on a starting page)
Page 1 contains this
<apex:pageBlock >
<apex:pageBlockTable value="{!objectField}" var="f">
<apex:column value="{!objectField[f][1]}" headerValue="SF Field"/>
<apex:column headerValue="Input Data">
<apex:selectList value="{!objectField[f][2]}" size="1">
<apex:selectOptions value="{!input}"/>
</apex:selectList>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
Page 2 is shows the result like this in a table (none is a value given when no data was inputted from page 1)
SF Field Input Data
Name Sam
Age 18
Gender Male
Country none
Status none
Blood Type O
Job none
My problem is I only want to display in Page 2 those rows that have values (not none) like this
SF Field Input Data
Name Sam
Age 18
Gender Male
Blood Type O
How do I do this?
Page 1 contains this
<apex:pageBlock >
<apex:pageBlockTable value="{!objectField}" var="f">
<apex:column value="{!objectField[f][1]}" headerValue="SF Field"/>
<apex:column headerValue="Input Data">
<apex:selectList value="{!objectField[f][2]}" size="1">
<apex:selectOptions value="{!input}"/>
</apex:selectList>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
Page 2 is shows the result like this in a table (none is a value given when no data was inputted from page 1)
SF Field Input Data
Name Sam
Age 18
Gender Male
Country none
Status none
Blood Type O
Job none
My problem is I only want to display in Page 2 those rows that have values (not none) like this
SF Field Input Data
Name Sam
Age 18
Gender Male
Blood Type O
How do I do this?
<script>
(function() {
mport = $("[id$=saveButton]");
mback = $("[id$=backButton]");
function disableSave() {
mport.attr("disabled","true");
mport.removeAttr("value");
mport.attr("value","IMPORTING...");
mback.attr("disabled","true");
}
function enableSave() {
mport.removeAttr("disabled");
mport.removeAttr("value");
mport.attr("value","IMPORT");
mback.removeAttr("disabled");
}
$('tr').each(function(){
var tr = $(this);
if (tr.find('td:eq(1)').text()=="none")
tr.addClass('hidden');
});
}());
</script>
<style>
.hidden{
display: none;
}
</style>
All Answers
You may be able to use the "rendered" attribute for the Visualforce elements that display those values on Page 2. Such as...
<apex:outputText value="{!Object__c.Field__c} rendered="{!Object__c.Field__c != 'none'}"/>
I have this block of code
<apex:column headerValue="CSV Field" value="{!objectFieldMap[field][3]}"/>
and I tried
<apex:column headerValue="CSV Field" value="{!objectFieldMap[field][3]}" rendered="{{!objectFieldMap[field][3]}!='none'}"/>
but I get this error
Visualforce ErrorHelp for this Page
Map key null not found in map
Error is in expression '{{!objectFieldMap[field][3]}!='none'}' in component <apex:page> in page nsert
any other method how?
I haven't found that Visualforce is able to check whether a map contains a key. In this case, the value for your FIELD variable is null, and even trying to check it by using rendered="{!objectFieldMap[field] != null}" would result in the same error.
I'm not sure where FIELD is coming from, whether it is a fixed list or something that is dynamically generated in the controller. Maybe your controller can provide a list of keys that are contained in the map, and you can loop through this list in Visualforce, using the values as keys with which to reference the map's values. This might be a way to ensure that the keys you are attempting to use in Visualforce are the actual keys from the map.
public List<String> getMapKeys() {
return new List<String>(objectFieldMap.keySet());
}
using this method, your page might then use <apex:repeat value="{!mapKeys}" var="eachKey">, and you would be sure to only use values that are from the map's keySet.
<apex:pageBlockTable value="{!objectFieldMap}" var="field">
<apex:column headerValue="SF Field" value="{!objectFieldMap[field][1]}" />
<apex:column headerValue="Input Data" value="{!objectFieldMap[field][3]}"/>
</apex:pageBlockTable>
</apex:pageBlock>
and the class contains this
public Map<String,List<String>> objectFieldMap {
get {
if(objectFieldMap == null) {
objectFieldMap = new Map<String,List<String>>();
}
return objectFieldMap;
}
set;
}
I hope this helps...
Map<String, List<String>> listMap = new Map<String, List<String>>{ 'test' => null };
So, I believe you are getting a null list as at least one of the values in your map.
<script>
(function() {
mport = $("[id$=saveButton]");
mback = $("[id$=backButton]");
function disableSave() {
mport.attr("disabled","true");
mport.removeAttr("value");
mport.attr("value","IMPORTING...");
mback.attr("disabled","true");
}
function enableSave() {
mport.removeAttr("disabled");
mport.removeAttr("value");
mport.attr("value","IMPORT");
mback.removeAttr("disabled");
}
$('tr').each(function(){
var tr = $(this);
if (tr.find('td:eq(1)').text()=="none")
tr.addClass('hidden');
});
}());
</script>
<style>
.hidden{
display: none;
}
</style>