通过 Apex 和 Visualforce (Salesforce web) 过滤报告

我正在尝试打印 Salesforce 自定义对象数据库并有一个过滤器。过滤器工作正常,但“全部”过滤器不会将完整表显示为默认值,或者当我从另一个过滤器中单击“全部”时。我怎样才能做到这一点?


这是相关的 Apex 代码:


public string itemPickValue{get; set;}

    public List<QC_Issue__c> issuesList{get; set;}

    public List<QC_Issue__c> results; 


    public List<QC_Issue__c> getIssues() {

        results = Database.query(

            'SELECT Component_Category__c, Issue_Name__c, Issue_Description__c, Severity_1_Criteria__c, Severity_2_Criteria__c, Severity_3_Criteria__c, File__c FROM QC_Issue__c Order By Component_Category__c, Issue_Name__c'


        );


        return results; 

    }


    public void getIssuesList() {

        if(itemPickValue.equals('All')) issuesList = Database.query('SELECT Component_Category__c, Issue_Name__c, Issue_Description__c, Severity_1_Criteria__c, Severity_2_Criteria__c, Severity_3_Criteria__c, File__c FROM QC_Issue__c');

        issuesList = Database.query('SELECT Component_Category__c, Issue_Name__c, Issue_Description__c, Severity_1_Criteria__c, Severity_2_Criteria__c, Severity_3_Criteria__c, File__c FROM QC_Issue__c WHERE Component_Category__c =: itemPickValue');

    }

这是相关的 Visualforce 代码:


<apex:pageBlock title="QC Glossary" id="qc_issues_list">

                <h3>Filter by Component Category:</h3>

                <br></br>

                <!-->Start Filter and List<-->

                    <apex:selectList size="1" value="{!itemPickValue}">

                        <apex:actionSupport event="onchange" action="{!getIssuesList}" rerender="table"/>

                            <apex:selectOption itemLabel="All" itemValue="All"></apex:selectOption>

                            <apex:selectOption itemLabel="Animation/VFX" itemValue="Animation/VFX"></apex:selectOption>

                    </apex:selectList>

                    <br></br>

                    <br></br>




牛魔王的故事
浏览 161回答 1
1回答

Qyouu

我进行了以下更改删除了代码重复,使用 getIssues 方法而不是复制 SOQL 语句。添加了一个 if/else 子句;你的主要问题是getIssuesList你有一个 if 语句,如果 true 将存储完整的结果issuesList,然后立即在下一行用过滤列表覆盖它,尝试使用类别名称“全部”这里还有很多其他的事情需要指出;但我暂时不说了。结果:public String itemPickValue{get; set;}public List<QC_Issue__c> issuesList{get; set;}public List<QC_Issue__c> results;&nbsp;public List<QC_Issue__c> getIssues() {&nbsp; &nbsp; results = Database.query(&nbsp; &nbsp; &nbsp; &nbsp; 'SELECT Component_Category__c, Issue_Name__c, Issue_Description__c, Severity_1_Criteria__c, Severity_2_Criteria__c, Severity_3_Criteria__c, File__c FROM QC_Issue__c Order By Component_Category__c, Issue_Name__c'&nbsp; &nbsp; );&nbsp; &nbsp; return results;&nbsp;}public void getIssuesList() {&nbsp; &nbsp; if(itemPickValue.equals('All')) {&nbsp; &nbsp; &nbsp; &nbsp; issuesList = getIssues();&nbsp; &nbsp; } else {&nbsp; &nbsp; &nbsp; &nbsp; issuesList = Database.query('SELECT Component_Category__c, Issue_Name__c, Issue_Description__c, Severity_1_Criteria__c, Severity_2_Criteria__c, Severity_3_Criteria__c, File__c FROM QC_Issue__c WHERE Component_Category__c =: itemPickValue');&nbsp; &nbsp; }}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java