Thread Rating:
  • 391 Vote(s) - 2.87 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RecordGrid で オートコンプリート
07-29-2011, 10:58 PM,
#2
RE: RecordGrid で オートコンプリート
ちょっと長いけどできました。

Code:
{define-proc public {filter-complete
                        list:StringArray,
                        prefix:String = "",
                        sort?:bool = true,
                        remove-blank?:bool = true
                    }:StringArray
    let values:Set = {Set}                     || Set of unique values
    let value-list:StringArray = {StringArray} || Values in order seen
    {for fv in list do
        {if fv == "" and remove-blank? then
            {continue}
        }
        {if not {values.member? fv} and
            {fv.prefix? prefix, ignore-case? = true}
         then
            {value-list.append fv}
            {values.insert fv}
        }
    }
    {if sort? then
        {value-list.sort}
    }
    {return value-list}
}

{define-class public open SimpleStringCellProvider
  {inherits AutocompleteProvider}
  
  field list:StringArray
  field protected cell:RecordGridCell
  
  {constructor public {default
                          cell:RecordGridCell,
                          max-results:int,
                          list:StringArray
                      }
    {construct-super max-results}
    set self.cell = cell
    set self.list = list
  }
  
  {method public open {refresh acf:AutocompleteMixin}:void
    {if-non-null record = self.cell.record then
        {if-non-null rs = record.record-set then
            {acf.populate-from-strings
                {filter-complete
                    self.list,
                    prefix = acf.text-field.value
                }
            }
            {return}
        }
    }
    {acf.populate-from-strings {StringArray}}
  }
}

{define-class public ExAutocompleteStringCell
  {inherits AutocompleteStringCell}
  
  field count:int = 10
  field list:StringArray = {StringArray}
  
  {constructor public {default }
    
  }
  {method public {create-editor}:TextField
    let editor:TextField =
        {super.create-editor} asa TextField
    
    set (editor asa SRGAutocompleteTextField).provider =
        {SimpleStringCellProvider
            self,
            self.count,
            self.list
        }
    {return editor}
  }
}
{define-class public SimpleCompleteCell
  {inherits ExAutocompleteStringCell}
  {constructor public {default }
    set self.list = {StringArray "aaa", "aab", "abb", "abc"}
    
  }
}

ExAutocompleteStringCell を継承して作ったSimpleCompleteCellを、RecordGridcolumn の cell-spec に渡してやればOKでした。


Messages In This Thread
RE: RecordGrid で オートコンプリート - by umemura - 07-29-2011, 10:58 PM

Possibly Related Threads...
Thread Author Replies Views Last Post
  RecordGrid の行の実際の高さの調べ方 kay 2 3,117 03-01-2016, 06:14 PM
Last Post: kay
  RecordGrid でDropdownList を表示 umemura 10 14,859 06-30-2015, 06:52 PM
Last Post: dyoshida
  RecordGrid 列の表示/非表示について Yudai-s 2 4,383 05-19-2015, 06:54 PM
Last Post: Yudai-s
  RecordGrid のセル単位のフォーカス制御方法 kay 2 3,286 03-06-2015, 06:34 PM
Last Post: kay
  RecordGrid のセルのフォーカス可否制御 kay 2 3,579 03-02-2015, 07:56 PM
Last Post: kay
  RecordGrid の縦のスクロールバー umemura 3 5,154 01-20-2014, 10:38 AM
Last Post: umemura
  RecordGrid のパフォーマンスについて umemura 8 12,787 01-06-2014, 02:34 PM
Last Post: umemura
  IME が使える オートコンプリート umemura 0 3,942 11-30-2011, 02:55 PM
Last Post: umemura
  RecordGrid の NavigationPanel について umemura 2 5,117 08-23-2011, 08:52 AM
Last Post: c-s
  RecordGrid での右詰め umemura 3 6,012 07-29-2011, 01:32 PM
Last Post: c-s
Forum Jump:


Users browsing this thread:
1 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('171')