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
PallavPallav 

Data display in the Datatable on the basis of the selection in the Select List

Greetings!!

I want to ask you two  questions:-

1. Is there any way in VF, where we can select a value from a "Selectlist" and upon selection of the that value the page will refresh and associated fields, or you can say details will be displayed.

2. with your help i have made the check box to appear inside the datalist but the header thing is not comming over there, how can I do that.

Thanks in anticipatino of your kind resolution to my issue.

regards
Pallav
thedgethedge
Page 25 of the VF Dev guide has a good example which is close to what you are trying to accomplish.
PallavPallav
Hi,

I have made a lot of ways to implement your suggestion but it is not helping me out with the cause. I have the id from the selectList but I am unable to pass it as parameter, like the way it is mentioned there.

here is my VF code:

<apex:page controller="AllPriceBookList" id="thePage" >
<apex:pageBlock>
<apex:form id="theForm">
<apex:selectList id="T1" value="{!Pricebook}" size="1" >
<apex:actionSupport event="onchange" action="somemethod" rerender="detail" />
<apex:selectOptions value="{!items}"/>
</apex:selectList>
</apex:form>
</apex:pageBlock>
<apex:outputPanel id="detail">
<apex:actionStatus startText="Requesting...">
<apex:detail subject="{!$CurrentPageReference.parameters.cid}" relatedList="false" title="false"/>
</apex:actionStatus>
</apex:outputPanel>
</apex:page>

and in the detail section there will be a dataTable, which I want to rerender on the change of the "SelectList " selection:

<apex:dataTable value="{!Entry}" var="PBData" id="theTable" border="2" cellspacing="2" cellpadding="2">
<apex:facet name="caption">Account Information</apex:facet>
<apex:facet name="header">~~Account information Starts here~~</apex:facet>
<apex:facet name="footer">~~Account information Ends here~~</apex:facet>
<apex:column>
<apex:facet name="check">Sno.</apex:facet>
<apex:outputText value=""/>
<apex:inputCheckbox id="theCheckbox"/>
</apex:column>
<apex:column>
<apex:facet name="header">Id</apex:facet>
<apex:outputText value="{!PBData.Id}"/>
</apex:column>
<apex:column>
<apex:facet name="header">Name</apex:facet>
<apex:outputText value="{!PBData.Name}"/>
</apex:column>
</apex:dataTable>


here is the Controller code, where getdata() method is not complete, which will fill query and fill the data for the the current selection in the selectlist in the dataTable:-

public class AllPriceBookList
{

public String getEntry() {
return null;
}

Map<Id,Pricebook2> priceBookMap = new Map<Id,Pricebook2>([select Id, Name from Pricebook2]);
String[] Pricebook = new String[]{};

public PageReference test()
{
return null;
}

public List<SelectOption> getItems()
{
List<SelectOption> options = new List<SelectOption>();
for(Pricebook2 act : priceBookMap.values())
{
Id actId = act.Id;
String Name = act.Name;
options.add(new SelectOption(actId,Name));
}
return options;
}

public String[] getPricebook()
{
return Pricebook;
}

public void setPricebook(String[] Pricebook)
{
this.Pricebook = Pricebook;
}

List<PricebookEntry> Entry;

public List<PricebookEntry> getData()
{
List<PricebookEntry> Entry= new List<PricebookEntry>();
return entry;
}

}

Pleaes let me know how to accomplish this.
Thanks in anticipation of your response.

regards
pallav


abhi_developerabhi_developer

Hi Pallav,

If i am not wrong, you want select list items to work as a link, like clicking on them displays their details.

Try setting list items to command links by <apex:commandlink> tab.

And set appropriate id values with <apex:param> tag.

Regards,

Abhishek singh

 

PallavPallav
Hi Abhishek,

Thanks for your response but I am wondering how can I make the<apex:selectlist> items in the <Apex:comandlist>, please respond in respect to my following code section:

<apex:page controller="AllPriceBookList" id="thePage" >

<apex:pageBlock>
<apex:form id="theForm">
<apex:selectList id="T1" value="{!Pricebook}" size="1" >
<apex:actionSupport event="onchange" action="{!getdata}" />
<apex:selectOptions value="{!items}"/>
</apex:selectList>
<apex:commandButton value="Go" action="{!test}" rerender="out"

status="status"/>

</apex:form>
</apex:pageBlock>
<apex:outputPanel id="detail">
<apex:actionStatus startText="Requesting...">
<apex:detail subject="{!$CurrentPageReference.parameters.id}"

relatedList="false" title="false">

<apex:form id="detailForm">
<apex:dataTable value="{!Entry}" var="PBData" id="theTable"

border="2" cellspacing="2" cellpadding="2">

<apex:facet name="caption">Product Detail

Information</apex:facet>
<apex:facet name="header">~~Product Detail information Starts

here~~</apex:facet>
<apex:facet name="footer">~~Product Detail information Ends

here~~</apex:facet>
<apex:column>
<apex:facet name="check">Sno.</apex:facet>
<apex:outputText value=""/>
<apex:inputCheckbox id="theCheckbox"/>
</apex:column>
<apex:column>
<apex:facet name="header">Id</apex:facet>
<apex:outputText value="{!PBData}"/>
</apex:column>
<apex:column>
<apex:facet name="header">Name</apex:facet>
<apex:outputText value="{!PBData}"/>
</apex:column>
</apex:dataTable>
</apex:form>
</apex:detail>
</apex:actionStatus>
</apex:outputPanel>
</apex:page>
abhi_developerabhi_developer
Hi pallav,
 
Instead of doing it like
<apex:selectList id="T1" value="{!Pricebook}" size="1" >.
<apex:actionSupport event="onchange" action="{!getdata}" />
 
Try it like
 
use
<apex:DataTable value="{!Pricebook}">

<apex:column>

<apex:commandLink rerender="detail"> //can render whatever you are displaying say {!getdata}.

<names_you_want_to_display_in_the_list>

<apex:param name="cid" value="{!Pricebook.id}"/>

</apex:commandLink>

</apex:column>

1. See what we are doing here is we are displaying pricebook contents as you have displayed with selected list. By wrapping pricebook into Datatable tag.

2. Turning them in to links with by wrapping them in to Command Link tag.

3. Setting Detail as item to be rendered. you can set it to whatever you want.

4. Setting id parameter appropiately with param tag.

5. Now clicking on different displayed items different details should be shown.

I am not fully aware of inner details so i have written a generalised algo. rather than code, just try this out.

 

PallavPallav
Thanks a lot for your productive response...

However the issue is that I need to have a selectlist and display of details on a dataTable. I should not use the suggestion that you are making (that is the requirement of project).

Please let me know if you have any suggestion for same thing implementing selectlist.

Thanks in anticiaption of your kind suggestion.

regards
pallav
dchasmandchasman
Pallev,

<apex:actionSupport> is a helkper component that must be the child of the component you are trying to add behavior to and in your example markup you had placed the actionSupport component as a peer of the selectList and that is not what you want.

You had:

<apex:selectList/>
<apex:actionSupport/>

instead of:

<apex:selectList>
  <apex:actionSupport/>
</apex:selectList>

and the difference is quite important. As the result of differences in the default event bubbling algoritms in different browsers your markup might appear to hook the event in FF, won't work at all in IE, but does not work correctly in any browser.


Message Edited by dchasman on 01-10-2008 01:31 PM
PallavPallav
Hi,

In my VF Code I have made the <apex:actionsupport> as child of <apex:selectList>.

<apex:selectList id="T1" value="{!Pricebook}" size="1" >
<apex:actionSupport event="onchange" action="{!getdata}" />
<apex:selectOptions value="{!items}"/>
</apex:selectList>

The issue is that when I used to mark selectlist as multiselect then the value selected from the selectlist is coming and I can use that value to display the details associated with it but what is my requirement is I want a selectlist with size="1". and when I select a item from it, then it should display the details either on the onchange of the selctlist or on the clicking of the command button, but it is not happening... as it is not able to capture the selected value from the selectlist to display the details of it.

what it will does is we have a list of PriceBook entries in the selct list when we select a perticular Price book then the detials of it should come in the grid format. here is the controler code that might help you understand my issue:-

public class AllPriceBookList
{

public String getProduct() {
return null;
}

public List<Pricebook2> getPricebook()
{
List<Pricebook2> Pricebook;
if (Pricebook==null) Pricebook=[Select Id, Name from Pricebook2];
return Pricebook;
}

List<Product2> Product;
public List<Product2> getData()
{
PricebookEntry [ ] PE = [Select Product2Id from PricebookEntry where Pricebook2Id=:

System.currentPageReference().getParameters().get('id')];
Set<Id> SetProduct2IDs = new Set<Id>();

for(PricebookEntry p: PE)
{
SetProduct2IDs.add(p.Product2Id );
}
if (Product==null) Product=[Select Id, Description, Family, Name from Product2 where Id In :SetProduct2IDs];
return Product;
}

}

Thanks in anticipation of your kind solution for the issue that I am facing.

regards
pallav