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
nobinekonobineko 

一覧画面の絞り込み方法

visualforceで一覧表示ページを作成中です。

ページ上部に抽出条件を入力する項目を作り、検索ボタンクリックで条件に合う情報を

抽出表示したいのですが、controller側のdoFindの処理はどういう方法がベストでしょうか?

 

よろしくお願いします。

 

apex:page controller="ListController">
 <apex:form >
  <apex:pageBlock>
   <apex:outputText value="Code"/>
   <apex:inputText id="Code" value="{!Code}"/>
   <apex:commandButton action="{!doFind}" value="検索" />
  </apex:pageBlock>
 
   <apex:pageBlock >
   <apex:pageBlockSection title=""  showHeader="false">
    <apex:dataTable value="{!List1}" var="l1">
     <apex:column>

 

ikouikou

ベストかどうかは分かりませんが、こんなんでどうでしょう。

 

 

取引先(Account)の電話番号(Phone)に対して部分一致で検索する感じです。

public with sharing class ListController{

  // 入力条件
  public String Code{get; set;}

  // 検索結果のリスト
  public Account List1{get; set;}

  // 検索メソッド
  public Pagereference doFind(){
    if(Code != null){
      String tmpCode = '%' + Code + '%';
      List1 = [SELECT Id, Name, Phone FROM Account WHERE Phone =: tmpCode];
    }
    return null;
  }
}

 ベストを考えると、特殊文字の対策とか、いろいろあると思いますけど。

nobinekonobineko

回答ありがとうございました。

 

List1の中身を書き換えないといけないんですね・・・

ListControllerのコンストラクタでなんとか出来ないか調べてたんですが、

javaの知識が無いと敷居が高いですね。