Thread Rating:
  • 340 Vote(s) - 2.66 Average
  • 1
  • 2
  • 3
  • 4
  • 5
グリッドのカラムを自動的に伸張させたい
12-20-2013, 03:32 PM,
#2
RE: グリッドのカラムを自動的に伸張させたい
とりあえず、ユーザの入力時だけ自動伸張することを前提にして、
update-data メソッドで実装してみました。


Code:
{let people:RecordSet =
    {RecordSet
        {RecordFields
            {RecordField "First", domain = String},
            {RecordField "Last", domain = String},
            {RecordField "Age", domain = int}
        },
        {RecordData First = "John", Last = "Smith", Age = 25},
        {RecordData First = "Jane", Last = "Smith", Age = 29},
        {RecordData First = "Jane", Last = "Jones", Age = 28}
    }
}
||自動伸張可能なカラム
{define-class public open ElasticCell
  {inherits StandardStringCell }

  {constructor public {default}
    {construct-super}
  }

  {method public open {update-data val:any}:#DataException
    let str-val:String = {self.format val}
    def current-col-width =
        {if-non-null self.column.width then
            {any-to-Distance self.column.width}
         else
            0pt
        }

    ||文字数×フォントサイズ ÷ 2 + 余白
    ||※実際は、文字のバイト数を取得したほうがよい
    def demanded-cell-width =
        {any-to-Distance  self.font-size} * str-val.size / 2 + 10pt

    set self.column.width = {max current-col-width, demanded-cell-width }

    {return {super.update-data val}}
  }
}

{value
    {RecordGrid
        record-source = people,
        {RecordGridColumn  "Last", cell-spec = ElasticCell}
    }
}


Messages In This Thread
RE: グリッドのカラムを自動的に伸張させたい - by umemura - 12-20-2013, 03:32 PM
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('1021')