简体   繁体   English

Visualforce 页面自定义过滤器

[英]Visualforce page custom filter

I have an Object, lets say 'Resources' Each object have type, lets say 'Contractors' Each 'Contractor' may have sub-types A, B, C, D我有一个对象,可以说“资源”每个对象都有类型,可以说“承包商”每个“承包商”可能有子类型 A、B、C、D

I have visualforce page setup that outputs all 'Contractors' as a table, but I also want to have Sub-types dropdown with A, B, C, D values with option to filter Contractors (Lets say, I select 'A', page will be refreshed, and all contractors with sub-type A appear).我有将所有“承包商”输出为表格的 Visualforce 页面设置,但我还希望有带有 A、B、C、D 值的子类型下拉列表,并带有筛选承包商的选项(比如说,我选择“A”,页面将被刷新,并且出现所有子类型 A 的承包商)。

Type and Sub-type are related list (Type is controlling field for sub-type)类型和子类型是相关列表(类型是子类型的控制字段)

I would really appreciate for your help.我真的很感激你的帮助。

Thank you.谢谢你。

I had sort of the same problem and this is how I developed it.我遇到了同样的问题,这就是我开发它的方式。

your Visual force page:您的视觉力页面:

 <apex:outputPanel id="PanelId">
    <apex:selectList size="1"  id="firstList" value="{!firstListVauleId}">              
        <apex:actionSupport event="onchange" action="{!UpdateSelectedFirstItem}" reRender="PanelId"/>
        <apex:selectOptions value="{!FirstListOptions}" />
      </apex:selectList>


      <apex:selectList size="1"  id="secondList" value="{!secondValueId}">              
        <apex:selectOptions value="{!SecondListOptions}" />
      </apex:selectList>

  </apex:outputPanel>

your apex class:你的顶级课程:

public String firstListVauleId {get;set;}
public String secondListVauleId {get;set;}
public List<SelectOption> getfirstListOptions()
{
    List<SelectOption> options = new List<SelectOption>();
    // add items add needed. you can make database queries.
    return options;
}

public List<SelectOption> getsecondListOptions()
{
    List<SelectOption> options = new List<SelectOption>();
    // add options based on the first list selection. you can make database queries.
    return options;
}


public void UpdateSelectedFirstItem()
{
    // do your stuff if you need to do anything upon changing the first dropdown selected item. 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM