<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>イージーネット Tech Blog &#187; ExtJS3.0</title>
	<atom:link href="http://blog.eni.co.jp/tech/tag/extjs30/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.eni.co.jp/tech</link>
	<description>株式会社イージーネットのスタッフによる技術系ブログです</description>
	<lastBuildDate>Tue, 12 Jan 2010 01:46:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.eni.co.jp/tech/tag/extjs30/feed" />
		<item>
		<title>ExtJS3.0でWebアプリケーションのテーブルをリッチにしよう（完）</title>
		<link>http://blog.eni.co.jp/tech/2010/01/extjs3_grid_table_last.html</link>
		<comments>http://blog.eni.co.jp/tech/2010/01/extjs3_grid_table_last.html#comments</comments>
		<pubDate>Tue, 12 Jan 2010 01:20:58 +0000</pubDate>
		<dc:creator>笹山 昭秀</dc:creator>
				<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Ext.grid.GridPanel]]></category>
		<category><![CDATA[Ext.Template]]></category>
		<category><![CDATA[Ext.ux.form.SearchField]]></category>
		<category><![CDATA[Ext.ux.grid.RowExpander]]></category>
		<category><![CDATA[ExtJS3.0]]></category>

		<guid isPermaLink="false">http://blog.eni.co.jp/tech/?p=1760</guid>
		<description><![CDATA[
このエントリーは下記の記事の続きです。
ExtJS3.0でWebアプリケーションのテーブルをリッチにしよう（その１）
ExtJS3.0でWebアプリケーションのテーブルをリッチにしよう（その２）

遅くなりましたが、明けましておめでとうございます。
笹山です。
前回の記事から更新が滞ってしまいました。（気づいたら2010年！）
記事用の時刻表ExtJSソースは準備していたのですが更新を怠けておりました。
（怠けている間にExt JS 3.1.0がリリースされておりました）
ですので必死で思い出しながら書きます。（本当に完全に忘れている・・・やばい。）
今回はExtJS3.0を用いて時刻表を作成する完結編です。
前回は、

ページング機能
Gridの高さ変更
Grid内のツールチップ表示

について書きましたが、やはり検索機能や飛行機の情報なんかも欲しくなるわけです。
今回は検索機能、飛行機の情報表示を実装してオレオレ時刻表の作成を終わりたいと思います。

検索機能の実装
検索機能の実装も難しくはありません。
実はExt.ux.data.PagingMemoryProxyのdoRequestメソッドにはすでにfiltering機能が備わっています。
前回Ext.ux.data.PagingMemoryProxyを使用したソートで問題があったので、オーバーライドしてoverride-paging-memory-proxy.jsを作成しました。
ですからoverride-paging-memory-proxy.jsを使用して検索機能を実装します。


override-paging-memory-proxy.js（フィルタリング部分）



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Ext.override&#40;Ext.ux.data.PagingMemoryProxy,&#123;
    doRequest: function&#40;action, rs, params, reader, callback, scope, options&#41;&#123;
&#160;
～　省略　～
&#160;
        // filtering
        if &#40;params.filter !== undefined&#41; &#123;
            result.records = result.records.filter&#40;function&#40;el&#41;&#123;
       [...]]]></description>
			<content:encoded><![CDATA[<div class="update">
このエントリーは下記の記事の続きです。</p>
<p><a href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part1.html">ExtJS3.0でWebアプリケーションのテーブルをリッチにしよう（その１）</a><br />
<a href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part2.html">ExtJS3.0でWebアプリケーションのテーブルをリッチにしよう（その２）</a>
</div>
<p>遅くなりましたが、明けましておめでとうございます。<br />
笹山です。</p>
<p><a href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part2.html" target="_blank">前回</a>の記事から更新が滞ってしまいました。（気づいたら2010年！）<br />
記事用の時刻表ExtJSソースは準備していたのですが更新を怠けておりました。<br />
（怠けている間に<a href="http://extjs.co.jp/products/extjs/download.php" target="_blank">Ext JS 3.1.0</a>がリリースされておりました）<br />
ですので必死で思い出しながら書きます。（本当に完全に忘れている・・・やばい。）</p>
<p>今回はExtJS3.0を用いて時刻表を作成する完結編です。<br />
<a href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part2.html" target="_blank">前回</a>は、</p>
<ul>
<li>ページング機能</li>
<li>Gridの高さ変更</li>
<li>Grid内のツールチップ表示</li>
</ul>
<p>について書きましたが、やはり検索機能や飛行機の情報なんかも欲しくなるわけです。<br />
今回は検索機能、飛行機の情報表示を実装してオレオレ時刻表の作成を終わりたいと思います。</p>
<p><span id="more-1760"></span></p>
<h3>検索機能の実装</h3>
<p>検索機能の実装も難しくはありません。<br />
実はExt.ux.data.PagingMemoryProxyのdoRequestメソッドにはすでにfiltering機能が備わっています。<br />
<a href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part2.html" target="_blank">前回</a>Ext.ux.data.PagingMemoryProxyを使用したソートで問題があったので、オーバーライドして<a href="http://blog.eni.co.jp/tech/misc/extjs/part2/override-paging-memory-proxy.js" target="_blank">override-paging-memory-proxy.js</a>を作成しました。<br />
ですから<a href="http://blog.eni.co.jp/tech/misc/extjs/part2/override-paging-memory-proxy.js" target="_blank">override-paging-memory-proxy.js</a>を使用して検索機能を実装します。</p>
<ul>
<li>
override-paging-memory-proxy.js（フィルタリング部分）
</li>
</ul>

<div class="wp_codebox"><table width="100%" ><tr id="p17607"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code" id="p1760code7"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">override</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">ux</span>.<span style="color: #660066;">data</span>.<span style="color: #660066;">PagingMemoryProxy</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
    doRequest<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>action<span style="color: #339933;">,</span> rs<span style="color: #339933;">,</span> params<span style="color: #339933;">,</span> reader<span style="color: #339933;">,</span> callback<span style="color: #339933;">,</span> scope<span style="color: #339933;">,</span> options<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
～　省略　～
&nbsp;
        <span style="color: #006600; font-style: italic;">// filtering</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">filter</span> <span style="color: #339933;">!==</span> undefined<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            result.<span style="color: #660066;">records</span> <span style="color: #339933;">=</span> result.<span style="color: #660066;">records</span>.<span style="color: #660066;">filter</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'object'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #003366; font-weight: bold;">var</span> att <span style="color: #339933;">=</span> params.<span style="color: #660066;">filterCol</span> <span style="color: #339933;">||</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">return</span> String<span style="color: #009900;">&#40;</span>el.<span style="color: #660066;">data</span><span style="color: #009900;">&#91;</span>att<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">filter</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000066; font-weight: bold;">return</span> String<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">filter</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            result.<span style="color: #660066;">totalRecords</span> <span style="color: #339933;">=</span> result.<span style="color: #660066;">records</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
～　省略　～</pre></td></tr></table></div>

<p>これを見るとリクエストパラメータに、「filterCol」と「filter」を指定すれば良いことが分かります。<br />
filterColでGridのカラム位置を指定して、「Gird要素内容」と「filter」をmatchメソッドを用いて検索を行っています。</p>
<p>それでは、Gridのカラムと検索文字列を指定して、Grid内のデータから検索ができるようにしてみます。<br />
「カラムを指定するためのComboBox」と「検索文字列を入力するFiled」をGridトップツールバーに作成します。<br />
<a href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part2.html" target="_blank">前回</a>の<a href="http://blog.eni.co.jp/tech/misc/extjs/part2/grid-timetable.js" target="_blank">grid-timetable.js</a>を編集して追加していきます。</p>
<h4>カラム指定のためのComboBox作成（Ext.form.ComboBox）</h4>
<p>まずは「検索カラムを指定するためのComboBox」をgrid-timetable.jsに作成します。</p>
<ul>
<li>
grid-timetable.js
</li>
</ul>

<div class="wp_codebox"><table width="100%" ><tr id="p17608"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
</pre></td><td class="code" id="p1760code8"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">onReady</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    Ext.<span style="color: #660066;">QuickTips</span>.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//</span>
    <span style="color: #006600; font-style: italic;">// カラムを指定するためのComboBox</span>
    <span style="color: #006600; font-style: italic;">//</span>
    <span style="color: #003366; font-weight: bold;">var</span> filterColCombo <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">form</span>.<span style="color: #660066;">ComboBox</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        id<span style="color: #339933;">:</span> <span style="color: #3366CC;">'filtercol_combo_id'</span><span style="color: #339933;">,</span>
        width<span style="color: #339933;">:</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">,</span>
        triggerAction<span style="color: #339933;">:</span> <span style="color: #3366CC;">'all'</span><span style="color: #339933;">,</span>
        valueField<span style="color: #339933;">:</span> <span style="color: #3366CC;">'value'</span><span style="color: #339933;">,</span>
        displayField <span style="color: #339933;">:</span> <span style="color: #3366CC;">'view'</span><span style="color: #339933;">,</span>
        value<span style="color: #339933;">:</span> <span style="color: #3366CC;">'flightName'</span><span style="color: #339933;">,</span>
        editable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>
        mode<span style="color: #339933;">:</span> <span style="color: #3366CC;">'local'</span><span style="color: #339933;">,</span>
        store<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">data</span>.<span style="color: #660066;">ArrayStore</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
            fields<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'view'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'value'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
            data<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'対象空港'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'destination'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'航空会社'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'airline'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'便名'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'flightName'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'機種'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'model'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'伊丹空港時間'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'itamiTime'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'対象空港時間'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'objectTime'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'出発/到着種別'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'type'</span><span style="color: #009900;">&#93;</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        listeners<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #3366CC;">'select'</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
                fn<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>combo<span style="color: #339933;">,</span> record<span style="color: #339933;">,</span> index<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    store.<span style="color: #660066;">baseParams</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
                        sort<span style="color: #339933;">:</span> <span style="color: #3366CC;">'itamiTime'</span><span style="color: #339933;">,</span>
                        dir<span style="color: #339933;">:</span> <span style="color: #3366CC;">'ASC'</span><span style="color: #339933;">,</span>
                        filterCol<span style="color: #339933;">:</span> record.<span style="color: #660066;">data</span>.<span style="color: #660066;">value</span><span style="color: #339933;">,</span>
                    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #3366CC;">'afterrender'</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
                fn<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>combo<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    store.<span style="color: #660066;">baseParams</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
                        sort<span style="color: #339933;">:</span> <span style="color: #3366CC;">'itamiTime'</span><span style="color: #339933;">,</span>
                        dir<span style="color: #339933;">:</span> <span style="color: #3366CC;">'ASC'</span><span style="color: #339933;">,</span>
                        filterCol<span style="color: #339933;">:</span> combo.<span style="color: #660066;">value</span><span style="color: #339933;">,</span>
                    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
                 <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
～　省略　～</pre></td></tr></table></div>

<p>詳細はExtJS3.0の<a href="http://docs.ext-japan.org/docs/" target="_blank">APIドキュメント（日本語）</a>も出たことですし、そちらを見ていただくとして、今回はポイントだけを書きます。</p>
<ul>
<li>
ComboBoxのValue値がGridカラムのdataIndex値と一致するようにComboBoxを作成します。これによりフィルタリング時にGridカラムから値を取り出すことが可能になります。
</li>
<li>
ComboBoxのイベント処理「select」で、ComboBoxが選択された後にリクエストパラメータを設定します。ComboBoxの選択値「record.data.value」をfilterColに設定、同時にソートフィールド、ソート方向も設定しています。
</li>
<li>
ComboBoxのイベント処理「afterrender」で、ComboBoxがレンダリングされた後にリクエストパラメータを設定します。ComboBoxの初期値「combo.value」をfilterColに設定、同時にソートフィールド、ソート方向も設定しています。
</li>
</ul>
<h4>検索文字列を入力するFiled作成（Ext.ux.form.SearchField）</h4>
<p>次に検索文字列を入力するFiledをgrid-timetable.jsに作成します。<br />
すでにExt.ux.form.SearchFieldという便利なコンポーネントが用意されています。</p>
<ul>
<li>
grid-timetable.js
</li>
</ul>

<div class="wp_codebox"><table width="100%" ><tr id="p17609"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="p1760code9"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">onReady</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    Ext.<span style="color: #660066;">QuickTips</span>.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> filterColCombo <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">form</span>.<span style="color: #660066;">ComboBox</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
&nbsp;
～　省略　～
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> store <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">data</span>.<span style="color: #660066;">Store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
&nbsp;
～　省略　～
&nbsp;
    <span style="color: #006600; font-style: italic;">//</span>
　　<span style="color: #006600; font-style: italic;">//　検索文字列を入力するFiled</span>
    <span style="color: #006600; font-style: italic;">//</span>
    <span style="color: #003366; font-weight: bold;">var</span> searchField <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">ux</span>.<span style="color: #660066;">form</span>.<span style="color: #660066;">SearchField</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        store<span style="color: #339933;">:</span> store<span style="color: #339933;">,</span>
        width<span style="color: #339933;">:</span> <span style="color: #CC0000;">200</span><span style="color: #339933;">,</span>
        paramName<span style="color: #339933;">:</span> <span style="color: #3366CC;">'filter'</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
～　省略　～</pre></td></tr></table></div>

<ul>
<li>
検索時のデータソースとして使用するstoreには、Gridで使用するものと同じstoreを指定します。
</li>
<li>
Ext.ux.form.SearchFieldのデフォルトのリクエストパラメータは「query」となっているため、「filter」に変更します。これでリクエストパラメータが「filter」となり、<a href="http://blog.eni.co.jp/tech/misc/extjs/part2/override-paging-memory-proxy.js" target="_blank">override-paging-memory-proxy.js</a>（フィルタリング部分）で使用できるようになります。</li>
</ul>
<h4>Gridトップツールバーへ追加</h4>
<p>先ほど作成した「カラムを指定するためのComboBox」と「検索文字列を入力するFiled」をGridトップツールバーに追加します。</p>
<ul>
<li>
grid-timetable.js
</li>
</ul>

<div class="wp_codebox"><table width="100%" ><tr id="p176010"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p1760code10"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">onReady</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    Ext.<span style="color: #660066;">QuickTips</span>.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
～　省略　～
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> grid <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">grid</span>.<span style="color: #660066;">GridPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
&nbsp;
～　省略　～
&nbsp;
        <span style="color: #006600; font-style: italic;">//</span>
        <span style="color: #006600; font-style: italic;">// Gridトップツールバー</span>
        <span style="color: #006600; font-style: italic;">//</span>
        tbar<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
            filterColCombo<span style="color: #339933;">,</span>
            searchField
        <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
&nbsp;
～　省略　～</pre></td></tr></table></div>

<ul>
<li>
GridPanelのトップツールバー(tbar)に、先ほど作成したfilterColComboとsearchFieldを指定します。
</li>
</ul>
<p>たったこれだけで検索機能は完成です。</p>
<div id="attachment_1944" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/12/combo_searchfield.PNG" target="_blank"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/12/combo_searchfield-300x140.PNG" alt="検索カラム指定ComboBoxと検索文字列入力Field" title="検索カラム指定ComboBoxと検索文字列入力Field" width="300" height="140" class="size-medium wp-image-1944"/></a><p class="wp-caption-text">検索カラム指定ComboBoxと検索文字列入力Field</p></div><br />
<center>↓</center><br />
<div id="attachment_1945" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/12/search_result.PNG" target="_blank"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/12/search_result-300x139.PNG" alt="便名指定からの検索結果" title="便名指定からの検索結果" width="300" height="139" class="size-medium wp-image-1945"　 /></a><p class="wp-caption-text">便名指定からの検索結果</p></div>
<h3>Grid内に画像付きの飛行機情報を表示する</h3>
<p>Gridに表示されている機種は「どんな飛行機なんだろう？」と思ったりしませんか？<br />
それでは、Ext.ux.grid.RowExpanderを使用して画像付きの簡単な機種情報が出るようにしてみようと思います。</p>
<h4>画像付きの飛行機情報表示機能作成（Ext.ux.grid.RowExpander）</h4>
<p>Ext.ux.grid.RowExpanderを使うと、Gridの各行に[+][-]アイコンを表示して、そのアイコンで行を伸縮し、付加情報を表示／非表示にすることができます。<br />
また表示する情報はExt.Templateを用いて自由にレイアウトすることができます。</p>
<ul>
<li>
grid-timetable.js
</li>
</ul>

<div class="wp_codebox"><table width="100%" ><tr id="p176011"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="p1760code11"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">onReady</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    Ext.<span style="color: #660066;">QuickTips</span>.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
～　省略　～
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> expander <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">ux</span>.<span style="color: #660066;">grid</span>.<span style="color: #660066;">RowExpander</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        tpl <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">Template</span><span style="color: #009900;">&#40;</span>
            <span style="color: #3366CC;">'&lt;table&gt;'</span><span style="color: #339933;">,</span>
            <span style="color: #3366CC;">'    &lt;tr&gt;'</span><span style="color: #339933;">,</span>
            <span style="color: #3366CC;">'        &lt;td&gt;'</span><span style="color: #339933;">,</span>
            <span style="color: #3366CC;">'            &lt;img src=&quot;../plainmodel/{airline}/{model}.jpg&quot; alt=&quot;{model}&quot;&gt;'</span><span style="color: #339933;">,</span>
            <span style="color: #3366CC;">'        &lt;/td&gt;'</span><span style="color: #339933;">,</span>
            <span style="color: #3366CC;">'        &lt;td&gt;'</span><span style="color: #339933;">,</span>
            <span style="color: #3366CC;">'            &lt;iframe src=&quot;../plainmodel/{airline}/{model}.html&quot; width=&quot;500&quot; height=&quot;100&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;'</span><span style="color: #339933;">,</span>
            <span style="color: #3366CC;">'        &lt;/td&gt;'</span><span style="color: #339933;">,</span>
            <span style="color: #3366CC;">'    &lt;/tr&gt;'</span><span style="color: #339933;">,</span>
            <span style="color: #3366CC;">'&lt;/table&gt;'</span>
        <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
～　省略　～</pre></td></tr></table></div>

<ul>
<li>
GridのColumns配列内にexpanderを作成するため、Ext.Template を使うことにより {キー名}の箇所がGrid dataIndexから取り出された値で置き換えられます。
</li>
<li>
{キー名}から取り出された値がフォルダ名、ファイル名となるようにしています。<br />
あらかじめ画像やHTMLが表示されるようにデータを準備して配置しています。<br /><strong>（例）{airline}キーの値がANA、{model}キーの値がB7の場合</strong>
<ul>
<li>img src=&#8221;../plainmodel/ANA/B7.jpg&#8221;</li>
<li>iframe src=&#8221;../plainmodel/ANA/B7.html&#8221;</li>
</ul>
</li>
</ul>
<h4>GridのColumns配列に追加</h4>
<p>先ほど作成したexpanderをGridのColumns配列に追加します。</p>
<ul>
<li>
grid-timetable.js
</li>
</ul>

<div class="wp_codebox"><table width="100%" ><tr id="p176012"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code" id="p1760code12"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">onReady</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    Ext.<span style="color: #660066;">QuickTips</span>.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
～　省略　～
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> grid <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">grid</span>.<span style="color: #660066;">GridPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        title<span style="color: #339933;">:</span> <span style="color: #3366CC;">'時刻表'</span><span style="color: #339933;">,</span>
        frame<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        height<span style="color: #339933;">:</span> <span style="color: #CC0000;">350</span><span style="color: #339933;">,</span>
        width<span style="color: #339933;">:</span> <span style="color: #CC0000;">750</span><span style="color: #339933;">,</span>
        renderTo<span style="color: #339933;">:</span> <span style="color: #3366CC;">'grid-timetable'</span><span style="color: #339933;">,</span>
        stripeRows<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        trackMouseOver<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        store<span style="color: #339933;">:</span> store<span style="color: #339933;">,</span>
            columns<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
　　　　　　　　　<span style="color: #006600; font-style: italic;">//</span>
                <span style="color: #006600; font-style: italic;">// 画像付きの飛行機情報を表示Expander</span>
                <span style="color: #006600; font-style: italic;">//</span>
                expander<span style="color: #339933;">,</span>　　<span style="color: #006600; font-style: italic;">//← ここ</span>
               <span style="color: #009900;">&#123;</span>
                  header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'対象空港'</span><span style="color: #339933;">,</span>
                  sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                  dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'destination'</span><span style="color: #339933;">,</span>
                  renderer<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>v<span style="color: #339933;">,</span> params<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                      params.<span style="color: #660066;">attr</span> <span style="color: #339933;">=</span> getQtipAttr<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;対象空港&quot;</span><span style="color: #339933;">,</span> v<span style="color: #339933;">,</span> 100<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                      <span style="color: #000066; font-weight: bold;">return</span> v<span style="color: #339933;">;</span>
                  <span style="color: #009900;">&#125;</span>
              <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
～　省略　～</pre></td></tr></table></div>

<p>たったこれだけで、こんなにリッチになります。どうですか？<br />
<div id="attachment_1964" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/12/grid_expander.PNG" target="_blank"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/12/grid_expander-300x141.PNG" alt="Grid Expander 画像付きの飛行機情報を表示する" title="Grid Expander 画像付きの飛行機情報を表示する" width="300" height="141" class="size-medium wp-image-1964" /></a><p class="wp-caption-text">Grid Expander 画像付きの飛行機情報を表示する</p></div></p>
<h3>今回のソースとデモ</h3>
<ul>
<li>
<a href="http://blog.eni.co.jp/tech/misc/extjs/part3/grid-timetable.html" target="_blank" >ExtJS3.0 Gridデモ「伊丹空港 12月時刻表」</a>
</li>
<li>
<a href="http://blog.eni.co.jp/tech/misc/extjs/part3/grid-timetable.js" target="_blank" >grid-timetable.js</a>
</li>
<li>
<a href="http://blog.eni.co.jp/tech/misc/extjs/part3/override-paging-memory-proxy.js" target="_blank" >override-paging-memory-proxy.js</a>
</li>
<li>
<a href="http://blog.eni.co.jp/tech/misc/extjs/data/timetable-data12.js" target="_blank" >timetable-data12.js</a>
</li>
</ul>
<p>※Grid中の飛行機画像は私が趣味で撮影した画像です。</p>
<h3>最後に</h3>
<p>時刻表の完成です。<br />
これでエアーバンドを聞きながら検索をかけて、しかも飛行機情報まで表示してくれます。<br />
ずいぶんと私好みの自己中心的な時刻表になってしまいました。</p>
<p>ExtJSで、ごりごり実装することもなく簡単にリッチなテーブルができることがお分かりいただけたと思います。<br />
余裕があるときに改造して「おれおれ時刻表」をパワーアップしていけたらと思っています。</p>
<h3>参考リンク</h3>
<ul>
<li>
<a href="http://www.extjs.com/">Ext</a>
</li>
<li>
<a href="http://extjs.co.jp/">Ext Japan</a>
</li>
<li>
<a href="http://www.extjs.com/deploy/dev/examples/samples.html">Ext JS 3.0 Samples</a>
</li>
<li>
<a href="http://www.extjs.com/deploy/dev/docs/">API Document</a>
</li>
<li>
<a href="http://docs.ext-japan.org/docs/" target="_blank">APIドキュメント（日本語）</a></li>
</ul>
<h3>あわせて読みたい</h3>
<ul>
<li><a href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part1.html">ExtJS3.0でWebアプリケーションのテーブルをリッチにしよう（その１）</a></li>
<li><a href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part2.html">ExtJS3.0でWebアプリケーションのテーブルをリッチにしよう（その２）</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.eni.co.jp/tech/2010/01/extjs3_grid_table_last.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.eni.co.jp/tech/2010/01/extjs3_grid_table_last.html" />
	</item>
		<item>
		<title>ExtJS3.0でWebアプリケーションのテーブルをリッチにしよう（その２）</title>
		<link>http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part2.html</link>
		<comments>http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part2.html#comments</comments>
		<pubDate>Tue, 08 Sep 2009 03:40:48 +0000</pubDate>
		<dc:creator>笹山 昭秀</dc:creator>
				<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Ext.grid.GridPanel]]></category>
		<category><![CDATA[Ext.override]]></category>
		<category><![CDATA[Ext.ux.data.PagingMemoryProxy]]></category>
		<category><![CDATA[Ext.ux.ProgressBarPager]]></category>
		<category><![CDATA[Ext.ux.SlidingPager]]></category>
		<category><![CDATA[ExtJS3.0]]></category>
		<category><![CDATA[オーバーライド]]></category>
		<category><![CDATA[ツールチップ]]></category>

		<guid isPermaLink="false">http://blog.eni.co.jp/tech/?p=1429</guid>
		<description><![CDATA[
このエントリーは下記の記事の続きです。
ExtJS3.0でWebアプリケーションのテーブルをリッチにしよう（その１）

こんにちは。笹山です。
前回Ext.grid.GridPanelを用いてシンプルな時刻表を作成しました。
まだまだ物足りないので機能を追加していきます。
せっかくなのでExtJS3.0の新機能を用いてもっとリッチにしていこうと思います。
（前回のGridは実際のところExtJS3.0でなくても作成できます。）
今回は以下の機能追加を行います。

ページング機能を追加する
Gridの高さを自由に変更可能にする
Gridの各Cellにマウスを合わせた時、内容をツールチップに表示する

※今回は全便の時刻表データを使ってサンプルを作成します（8月時刻表全便データ）

新機能ライブラリの追加
ExtJS3.0のサンプルサイトで紹介されている新機能を使用するには、新機能用のライブラリが必要です。
新機能用のライブラリは、ExtJS3.0を展開したexmaple\uxフォルダ以下にあります。（新機能なのに何でexampleフォルダなんだろう？）
必要なファイルは以下になります。

ext-3.0.0\examples\ux\ux-all.js
ext-3.0.0\examples\ux\css\ux-all.css
ext-3.0.0\examples\ux\images以下のファイル全て

前回作成したサンプルをもとに変更を加えていきます。

grid-timetable.htmlのHEADタグ内に「新機能に必要なファイル」と「全便の時刻表データファイル」を追加します
※override-paging-memory-proxy.jsについては新規作成します

1
2
3
4
  &#60;link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; href=&#34;path/ux-all.css&#34; /&#62;
  &#60;script type=&#34;text/javascript&#34; src=&#34;path/ux-all.js&#34;&#62;&#60;/script&#62;
  &#60;script type=&#34;text/javascript&#34; src=&#34;path/timetable-data.js&#34;&#62;&#60;/script&#62;
  &#60;script type=&#34;text/javascript&#34; src=&#34;path/override-paging-memory-proxy.js&#34;&#62;&#60;/script&#62;

※linkタグ、scriptタグ中の「path」 : ファイルを配置したディレクトリ名に変更してください


grid-timetable.html


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
&#60;!DOCTYPE HTML PUBLIC &#34;-//W3C//DTD HTML 4.01 Transitional//EN&#34;
&#34;http://www.w3.org/TR/html4/loose.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62;
    &#60;head&#62;
        &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=utf-8&#34; /&#62;
        &#60;link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; href=&#34;path/ext-all.css&#34; [...]]]></description>
			<content:encoded><![CDATA[<div class="update">
このエントリーは下記の記事の続きです。</p>
<p><a href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part1.html">ExtJS3.0でWebアプリケーションのテーブルをリッチにしよう（その１）</a>
</div>
<p>こんにちは。笹山です。</p>
<p><a href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part1.html">前回</a>Ext.grid.GridPanelを用いてシンプルな時刻表を作成しました。</p>
<p>まだまだ物足りないので機能を追加していきます。<br />
せっかくなのでExtJS3.0の新機能を用いてもっとリッチにしていこうと思います。<br />
（<a href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part1.html">前回</a>のGridは実際のところExtJS3.0でなくても作成できます。）</p>
<p>今回は以下の機能追加を行います。</p>
<ul>
<li>ページング機能を追加する</li>
<li>Gridの高さを自由に変更可能にする</li>
<li>Gridの各Cellにマウスを合わせた時、内容をツールチップに表示する</li>
</ul>
<p>※今回は全便の時刻表データを使ってサンプルを作成します（<a href="http://blog.eni.co.jp/tech/misc/extjs/data/timetable-data.js">8月時刻表全便データ</a>）</p>
<p><span id="more-1429"></span></p>
<h3>新機能ライブラリの追加</h3>
<p>ExtJS3.0のサンプルサイトで紹介されている新機能を使用するには、新機能用のライブラリが必要です。<br />
新機能用のライブラリは、ExtJS3.0を展開したexmaple\uxフォルダ以下にあります。（新機能なのに何でexampleフォルダなんだろう？）</p>
<p>必要なファイルは以下になります。</p>
<ul>
<li>ext-3.0.0\examples\ux\ux-all.js</li>
<li>ext-3.0.0\examples\ux\css\ux-all.css</li>
<li>ext-3.0.0\examples\ux\images以下のファイル全て</li>
</ul>
<p><a href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part1.html">前回</a>作成したサンプルをもとに変更を加えていきます。</p>
<ul>
<li>grid-timetable.htmlのHEADタグ内に「新機能に必要なファイル」と「全便の時刻表データファイル」を追加します<br />
<span style="color: #ff0000;">※</span><a href="#override-paging-memory-proxy">override-paging-memory-proxy.jsについては新規作成します</a></p>

<div class="wp_codebox"><table width="100%" ><tr id="p142920"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p1429code20"><pre class="html" style="font-family:monospace;">  &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;path/ux-all.css&quot; /&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;path/ux-all.js&quot;&gt;&lt;/script&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;path/timetable-data.js&quot;&gt;&lt;/script&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;path/override-paging-memory-proxy.js&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<p><span style="color: #ff0000;">※linkタグ、scriptタグ中の「path」 : ファイルを配置したディレクトリ名に変更してください</span></li>
</ul>
<ul>
<li>grid-timetable.html</li>
</ul>

<div class="wp_codebox"><table width="100%" ><tr id="p142921"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="p1429code21"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;
&quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
    &lt;head&gt;
        &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
        &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;path/ext-all.css&quot; /&gt;
        &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;path/ux-all.css&quot; /&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;path/ext-base.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;path/ext-all.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;path/ux-all.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;path/ext-lang-ja.js&quot; charset=&quot;UTF-8&quot;&gt;&lt;/script&gt;
&nbsp;
        &lt;script type=&quot;text/javascript&quot; src=&quot;path/timetable-data.js&quot;&gt;&lt;/script&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;path/override-paging-memory-proxy.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;path/grid-timetable.js&quot;&gt;&lt;/script&gt;
        &lt;title&gt;伊丹空港 8月時刻表&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;h1&gt;伊丹空港 8月時刻表&lt;/h1&gt;
        &lt;div id=&quot;grid-timetable&quot;&gt;&lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p><a name="override-paging-memory-proxy"></a></p>
<h3>Ext.ux.data.PagingMemoryProxyのメソッドオーバーライド</h3>
<p>Ext.ux.data.PagingMemoryProxyを利用したサンプルを作成している際に以下のバグを発見しました。</p>
<ul>
<li>Gridのカラムソートの昇順、降順が逆に処理される</li>
<li>Gridのカラムソートの降順が正常に動作しない（最後のデータから表示しているだけ）</li>
</ul>
<p>これを修正するためにExt.ux.data.PagingMemoryProxyのdoRequest メソッドのオーバーライドを行います。<br />
エディタで新しいファイルoverride-paging-memory-proxy.jsを作成します。</p>
<ul>
<li>override-paging-memory-proxy.js(新規作成)</li>
</ul>

<div class="wp_codebox"><table width="100%" ><tr id="p142922"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
</pre></td><td class="code" id="p1429code22"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">override</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">ux</span>.<span style="color: #660066;">data</span>.<span style="color: #660066;">PagingMemoryProxy</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
    doRequest<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>action<span style="color: #339933;">,</span> rs<span style="color: #339933;">,</span> params<span style="color: #339933;">,</span> reader<span style="color: #339933;">,</span> callback<span style="color: #339933;">,</span> scope<span style="color: #339933;">,</span> options<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        params <span style="color: #339933;">=</span> params <span style="color: #339933;">||</span>
        <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> result<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            result <span style="color: #339933;">=</span> reader.<span style="color: #660066;">readRecords</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">fireEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'loadexception'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> options<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            callback.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span>scope<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> options<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// filtering</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">filter</span> <span style="color: #339933;">!==</span> undefined<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            result.<span style="color: #660066;">records</span> <span style="color: #339933;">=</span> result.<span style="color: #660066;">records</span>.<span style="color: #660066;">filter</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'object'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #003366; font-weight: bold;">var</span> att <span style="color: #339933;">=</span> params.<span style="color: #660066;">filterCol</span> <span style="color: #339933;">||</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">return</span> String<span style="color: #009900;">&#40;</span>el.<span style="color: #660066;">data</span><span style="color: #009900;">&#91;</span>att<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">filter</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000066; font-weight: bold;">return</span> String<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">filter</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            result.<span style="color: #660066;">totalRecords</span> <span style="color: #339933;">=</span> result.<span style="color: #660066;">records</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// sorting</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">sort</span> <span style="color: #339933;">!==</span> undefined<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// use integer as params.sort to specify column, since arrays are not named</span>
            <span style="color: #006600; font-style: italic;">// params.sort=0; would also match a array without columns</span>
            <span style="color: #003366; font-weight: bold;">var</span> dir <span style="color: #339933;">=</span> String<span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">dir</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toUpperCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'DESC'</span> <span style="color: #339933;">?</span> <span style="color: #339933;">-</span>1 <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> fn <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>r1<span style="color: #339933;">,</span> r2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">return</span> r1 <span style="color: #339933;">==</span> r2 <span style="color: #339933;">?</span> 0 <span style="color: #339933;">:</span> r1 <span style="color: #339933;">&lt;</span> r2 <span style="color: #339933;">?</span> <span style="color: #339933;">-</span>1 <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
　　　　　　　　<span style="color: #006600; font-style: italic;">/* ↑↑↑↑↑↑↑↑↑↑↑↑ ※ux-all.jsでは、 return r1 &lt; r2; になっています */</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
            result.<span style="color: #660066;">records</span>.<span style="color: #660066;">sort</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> v <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'object'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    v <span style="color: #339933;">=</span> fn<span style="color: #009900;">&#40;</span>a.<span style="color: #660066;">data</span><span style="color: #009900;">&#91;</span>params.<span style="color: #660066;">sort</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> b.<span style="color: #660066;">data</span><span style="color: #009900;">&#91;</span>params.<span style="color: #660066;">sort</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> dir<span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                    v <span style="color: #339933;">=</span> fn<span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> dir<span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>v <span style="color: #339933;">==</span> 0<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    v <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>a.<span style="color: #660066;">index</span> <span style="color: #339933;">&lt;</span> b.<span style="color: #660066;">index</span> <span style="color: #339933;">?</span> <span style="color: #339933;">-</span>1 <span style="color: #339933;">:</span> 1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000066; font-weight: bold;">return</span> v<span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// paging (use undefined cause start can also be 0 (thus false))</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">start</span> <span style="color: #339933;">!==</span> undefined <span style="color: #339933;">&amp;&amp;</span> params.<span style="color: #660066;">limit</span> <span style="color: #339933;">!==</span> undefined<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            result.<span style="color: #660066;">records</span> <span style="color: #339933;">=</span> result.<span style="color: #660066;">records</span>.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span>params.<span style="color: #660066;">start</span><span style="color: #339933;">,</span> params.<span style="color: #660066;">start</span> <span style="color: #339933;">+</span> params.<span style="color: #660066;">limit</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        callback.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span>scope<span style="color: #339933;">,</span> result<span style="color: #339933;">,</span> options<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<table class="content" width="100%">
<caption style="text-align: left; "><strong>Ext<strong/></caption>
<tr>
<th width="150">
            Methods
        </th>
<th>
            説明
        </th>
</tr>
<tr>
<td>
            override
        </td>
<td>
既存クラスのメソッドをオーバーライドします<br />メソッドが存在しない場合は追加されます
        </td>
</tr>
</table>
<p>作成したoverride-paging-memory-proxy.jsをgrid-timetable.htmlに追加してください。</p>
<h3>ページング機能を追加する</h3>
<p><a href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part1.html">前回</a>はExt.data.ArrayStoreを使用して配列をそのままStoreに渡していましたが、今回はExt.data.Storeのproxyを使用してデータを取得します。<br />
Storeはproxyを使用して外部データを取得します。proxyにはJSON形式でデータを取得するHttpProxyやメモリ内のデータを取得するためのExt.data.MemoryProxyがあります。<br />
今回使用するExt.ux.data.PagingMemoryProxyはExt.data.MemoryProxyが拡張されたものでメモリ内のデータのページングやソートを行うことができます。</p>
<p>それでは、<a href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part1.html">前回</a>のgrid-timetable.jsにページング機能を追加してきます。</p>
<ul>
<li>「全便の時刻表データファイル」を使用しますので、ソース中に直接書いていたtimeTableData配列を削除します</li>
<li>（変更①） StoreをExt.data.ArrayStoreからExt.data.Storeへ変更しproxyからデータを取得するようにします</li>
<li>（変更②） Ext.grid.GridPanelのBottomToolbarにExt.PagingToolbarを作成します</li>
<li>（変更③） Storeへロードを行う際に、HTTPパラメータを指定してデータをロードします</li>
</ul>
<p />
<ul>
<li>grid-timetable.js</li>
</ul>

<div class="wp_codebox"><table width="100%" ><tr id="p142923"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
</pre></td><td class="code" id="p1429code23"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">onReady</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> store <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">data</span>.<span style="color: #660066;">Store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>                                <span style="color: #009966; font-style: italic;">/* 変更① ここから */</span>
        proxy<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">ux</span>.<span style="color: #660066;">data</span>.<span style="color: #660066;">PagingMemoryProxy</span><span style="color: #009900;">&#40;</span>timeTableData<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        remoteSort<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        baseParams<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>sort<span style="color: #339933;">:</span> <span style="color: #3366CC;">'itamiTime'</span><span style="color: #339933;">,</span> dir<span style="color: #339933;">:</span> <span style="color: #3366CC;">'ASC'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
        reader<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">data</span>.<span style="color: #660066;">ArrayReader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
            fields<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'destination'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'airline'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'flightName'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'model'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'itamiTime'</span><span style="color: #339933;">,</span> type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'date'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'objectTime'</span><span style="color: #339933;">,</span> type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'date'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'type'</span><span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>                                                          <span style="color: #009966; font-style: italic;">/* 変更① ここまで */</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> grid <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">grid</span>.<span style="color: #660066;">GridPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        title<span style="color: #339933;">:</span> <span style="color: #3366CC;">'時刻表'</span><span style="color: #339933;">,</span>
        frame<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        height<span style="color: #339933;">:</span> <span style="color: #CC0000;">350</span><span style="color: #339933;">,</span>
        width<span style="color: #339933;">:</span> <span style="color: #CC0000;">750</span><span style="color: #339933;">,</span>
        renderTo<span style="color: #339933;">:</span> <span style="color: #3366CC;">'grid-timetable'</span><span style="color: #339933;">,</span>
        stripeRows<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        trackMouseOver<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        store<span style="color: #339933;">:</span> store<span style="color: #339933;">,</span>
        columns<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'対象空港'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'destination'</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'航空会社'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'airline'</span><span style="color: #339933;">,</span>
                renderer<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>v<span style="color: #339933;">,</span> params<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                    <span style="color: #003366; font-weight: bold;">var</span> airlineColor <span style="color: #339933;">=</span> v<span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>v <span style="color: #339933;">==</span> <span style="color: #3366CC;">'ANA'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        airlineColor <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;span style=&quot;color: #003399;&quot;&gt;'</span> <span style="color: #339933;">+</span> v <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>v <span style="color: #339933;">==</span> <span style="color: #3366CC;">'JAL'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        airlineColor <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;span style=&quot;color: #cc0000;&quot;&gt;'</span> <span style="color: #339933;">+</span> v <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>v <span style="color: #339933;">==</span> <span style="color: #3366CC;">'IBEX'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        airlineColor <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;span style=&quot;color: #F552A8;&quot;&gt;'</span> <span style="color: #339933;">+</span> v <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #003366; font-weight: bold;">var</span> codeShare <span style="color: #339933;">=</span> v.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>codeShare.<span style="color: #660066;">length</span> <span style="color: #339933;">==</span> 2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>codeShare<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'IBEX'</span> <span style="color: #339933;">&amp;&amp;</span> codeShare<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'ANA'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                                airlineColor <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;span style=&quot;color: #F552A8;&quot;&gt;'</span> <span style="color: #339933;">+</span> 
                                    codeShare<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/span&gt;'</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'/'</span> <span style="color: #339933;">+</span> 
                                    <span style="color: #3366CC;">'&lt;span style=&quot;color: #003399;&quot;&gt;'</span> <span style="color: #339933;">+</span> codeShare<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span>
                            <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                                <span style="color: #006600; font-style: italic;">// 何もしない</span>
                            <span style="color: #009900;">&#125;</span>
                        <span style="color: #009900;">&#125;</span>
                    <span style="color: #009900;">&#125;</span>
                    <span style="color: #000066; font-weight: bold;">return</span> airlineColor<span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'便名'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'flightName'</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'機種'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'model'</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'伊丹空港時間'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'itamiTime'</span><span style="color: #339933;">,</span>
                renderer<span style="color: #339933;">:</span> Ext.<span style="color: #660066;">util</span>.<span style="color: #660066;">Format</span>.<span style="color: #660066;">dateRenderer</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'H:i'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'対象空港時間'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'objectTime'</span><span style="color: #339933;">,</span>
                renderer<span style="color: #339933;">:</span> Ext.<span style="color: #660066;">util</span>.<span style="color: #660066;">Format</span>.<span style="color: #660066;">dateRenderer</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'H:i'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'出発/到着種別'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'type'</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        bbar<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">PagingToolbar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>                            <span style="color: #009966; font-style: italic;">/* 変更② ここから */</span>
            pageSize<span style="color: #339933;">:</span> 30<span style="color: #339933;">,</span>
            store<span style="color: #339933;">:</span> store<span style="color: #339933;">,</span>
            displayInfo<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>                                                        <span style="color: #009966; font-style: italic;">/* 変更② ここまで */</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    store.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>                                                 <span style="color: #009966; font-style: italic;">/* 変更③ ここから */</span>
        params<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
            start<span style="color: #339933;">:</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
            limit<span style="color: #339933;">:</span><span style="color: #CC0000;">30</span><span style="color: #339933;">,</span>
            sort<span style="color: #339933;">:</span><span style="color: #3366CC;">'itamiTime'</span><span style="color: #339933;">,</span>
            dir<span style="color: #339933;">:</span> <span style="color: #3366CC;">'ASC'</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                                                          <span style="color: #009966; font-style: italic;">/* 変更③ ここまで */</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<ul>
<li>変更①　2行目～17行目<br />
<table class="content" width="100%">
<caption style="text-align: left; "><strong>Ext.data.Store<strong/></caption>
<tr>
<th width="150">
        	Config Options
        </th>
<th colspan="2">
        	説明
        </th>
</tr>
<tr>
<td>
        	proxy
        </td>
<td colspan="2">
        	データオブジェクトへのアクセスを提供するプロキシーオブジェクトを指定します
        </td>
</tr>
<tr>
<td>
        	remoteSort
        </td>
<td colspan="2">
        	true：並び替えをproxyに要求して処理します<br />
                false：キャッシュ中のデータ（現在Grid表示されているデータ）で並び替えを行います
        </td>
</tr>
<tr>
<td rowspan="4">
        	baseParams
        </td>
<td colspan="2">
HTTP リクエスト時に常に送られるパラメータのオブジェクトです<br />
Ext.ux.data.PagingMemoryProxyではstart,limit,sort,dir,filterのパラメータを受け取り、処理が可能です<br />
start,limitパラメータはbaseParamsを指定しなくてもページング処理の際、自動で設定されます
        </td>
</tr>
<tr>
<th width="100">
        	パラメータ
        </th>
<th>
        	説明
        </th>
</tr>
<tr>
<td>
        	sort
        </td>
<td>
ソートする項目名を指定します
        </td>
</tr>
<tr>
<td>
        	dir
        </td>
<td>
ソートする方向を指定します
        </td>
</tr>
<tr>
<td>
        	reader
        </td>
<td colspan="2">
DataReader オブジェクトを指定します
        </td>
</tr>
</table>
<p></p>
<table class="content" width="100%">
<caption style="text-align: left; "><strong>Ext.ux.data.PagingMemoryProxy<strong/></caption>
<tr>
<th width="150">
        	Config Options
        </th>
<th colspan="2">
        	説明
        </th>
</tr>
<tr>
<td>
        	-
        </td>
<td colspan="2">
ページンググリッドが可能なMemoryProxyです（メモリ内のデータから読み込みます）
        </td>
</tr>
</table>
<p></p>
<table class="content" width="100%">
<caption style="text-align: left; "><strong>Ext.data.ArrayReader<strong/></caption>
<tr>
<th width="150">
        	Config Options
        </th>
<th colspan="2">
        	説明
        </th>
</tr>
<tr>
<td rowspan="4">
        	fields
        </td>
<td colspan="2">
データをどのようにマッピングするか定義します
        </td>
</tr>
<tr>
<th width="100">
        	パラメータ
        </th>
<th>
        	説明
        </th>
</tr>
<tr>
<td>
        	name
        </td>
<td>
レコード内でfieldを参照する際に用いるnameです<br /> ColumnModelのdataIndexプロパティによって参照されます
        </td>
</tr>
<tr>
<td>
        	type
        </td>
<td>
表示できる値に変換するためのデータタイプです<br />指定しない場合は、autoとなり変換を行いません
        </td>
</tr>
</table>
</li>
<li>変更②　89行目～93行目<br />
<table class="content" width="100%">
<caption style="text-align: left; "><strong>Ext.grid.GridPanel<strong/></caption>
<tr>
<th width="150">
        	Config Options
        </th>
<th colspan="2">
        	説明
        </th>
</tr>
<tr>
<td>
        	bbar
        </td>
<td colspan="2">
Gridパネル下部のツールバーです
        </td>
</tr>
</table>
<table class="content" width="100%">
<caption style="text-align: left; "><strong>Ext.PagingToolbar<strong/></caption>
<tr>
<th width="150">
        	Config Options
        </th>
<th colspan="2">
        	説明
        </th>
</tr>
<tr>
<td>
        	pageSize
        </td>
<td colspan="2">
1ページ単位で表示するデータの数です
        </td>
</tr>
<tr>
<td>
        	store
        </td>
<td colspan="2">
ページングツールバーがデータソースとして使用するExt.data.Storeを指定します
        </td>
</tr>
<tr>
<td>
        	displayInfo
        </td>
<td colspan="2">
displayMsg(ページングステータスメッセージ)を表示します
        </td>
</tr>
</table>
</li>
<li>変更③　96行目～103行目<br />
<table class="content" width="100%">
<caption style="text-align: left; "><strong>Ext.grid.GridPanel<strong/></caption>
<tr>
<th width="150">
        	Methods
        </th>
<th colspan="2">
        	説明
        </th>
</tr>
<tr>
<td rowspan="4">
        	load
        </td>
<td colspan="2">
設定されたReaderを用いてProxyからレコードキャッシュをロードします
        </td>
</tr>
<tr>
<th width="100">
        	Options
        </th>
<th>
        	説明
        </th>
</tr>
<tr>
<td>
params
        </td>
<td>
リモートデータソースに対してHTTPパラメータとして渡すプロパティを指定します<br />
Ext.ux.data.PagingMemoryProxyでは以下のパラメータを受け取り、処理が可能です<br />
start:データ開始位置<br />
limit:1ページ当たりのデータ件数<br />
sort:ソートする項目名<br />
dir:ソートする方向
        </td>
</tr>
</table>
</li>
</ul>
<p />
<div id="attachment_1647" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/09/itm_timetable_paging.png"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/09/itm_timetable_paging-300x141.png" alt="Grid(時刻表)ページング機能" title="ページング機能" width="300" height="141" class="size-medium wp-image-1647" /></a><p class="wp-caption-text">Grid(時刻表)ページング機能</p></div></p>
<p>たったこれだけの変更でページング機能が実現できます。今回はメモリ内のデータでページング機能を行いました。proxyをExt.data.HttpProxyに変更すれば、サーバからXML、JSON形式でデータを取得してこれを実現することが可能です。</p>
<h3>ページング機能を拡張する</h3>
<p>ExtJS3.0の新しい機能でページングの機能を簡単に便利に、カッコ良くできます。</p>
<ul>
<li>（拡張①）スライドでページング可能にする</li>
<li>（拡張②）プログレスバーで進捗確認、ページング可能にする</li>
</ul>
<ul>
<li>grid-timetable.js</li>
</ul>

<div class="wp_codebox"><table width="100%" ><tr id="p142924"><td class="line_numbers"><pre>19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
</pre></td><td class="code" id="p1429code24"><pre class="javascript" style="font-family:monospace;">    <span style="color: #003366; font-weight: bold;">var</span> grid <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">grid</span>.<span style="color: #660066;">GridPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
&nbsp;
               <span style="color: #006600; font-style: italic;">// ～省略</span>
&nbsp;
        bbar<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">PagingToolbar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
            pageSize<span style="color: #339933;">:</span> 30<span style="color: #339933;">,</span>
            store<span style="color: #339933;">:</span> store<span style="color: #339933;">,</span>
            displayInfo<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
            plugins<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">ux</span>.<span style="color: #660066;">SlidingPager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>          <span style="color: #009966; font-style: italic;">/* 拡張① */</span>
                <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">ux</span>.<span style="color: #660066;">ProgressBarPager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>       <span style="color: #009966; font-style: italic;">/* 拡張② */</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
&nbsp;
               <span style="color: #006600; font-style: italic;">// ～省略</span></pre></td></tr></table></div>

<div id="attachment_1665" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/09/itm_timetable_paging_plugin.png"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/09/itm_timetable_paging_plugin-300x141.png" alt="Grid(時刻表)ページング機能拡張（SlidingPager,ProgressBarPager）" title="Grid(時刻表)ページング機能拡張（SlidingPager,ProgressBarPager）" width="300" height="141" class="size-medium wp-image-1665" /></a><p class="wp-caption-text">Grid(時刻表)ページング機能拡張（SlidingPager,ProgressBarPager）</p></div>
<p>たったこれだけです。<br />
Ext.PagingToolbarのpluginsオプションに指定するだけで簡単に実現できます。</p>
<h3>Gridの高さを任意のサイズに変更可能にする</h3>
<p>ここまでのGrid(時刻表)高さは固定でした。<br />
データがサイズ内に収まらない場合は、スクロールして見る必要がありました。<br />
そこでGrid(時刻表)の高さを任意のサイズに変更できるようにします。</p>
<ul>
<li>（拡張③）Grid(時刻表)の高さを任意のサイズに変更可能にする</li>
</ul>
<ul>
<li>grid-timetable.js</li>
</ul>

<div class="wp_codebox"><table width="100%" ><tr id="p142925"><td class="line_numbers"><pre>19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code" id="p1429code25"><pre class="javascript" style="font-family:monospace;">    <span style="color: #003366; font-weight: bold;">var</span> grid <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">grid</span>.<span style="color: #660066;">GridPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
&nbsp;
               <span style="color: #006600; font-style: italic;">// ～省略</span>
&nbsp;
        plugins<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">ux</span>.<span style="color: #660066;">PanelResizer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>  <span style="color: #009966; font-style: italic;">/* 拡張③ ここから */</span>
            minHeight<span style="color: #339933;">:</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">,</span>
            maxHeight<span style="color: #339933;">:</span> <span style="color: #CC0000;">800</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>                                <span style="color: #009966; font-style: italic;">/* 拡張③ ここまで */</span>
&nbsp;
               <span style="color: #006600; font-style: italic;">// ～省略</span></pre></td></tr></table></div>

<table class="content" width="100%">
<caption style="text-align: left; "><strong>Ext.ux.PanelResizer<strong/></caption>
<tr>
<th width="150">
        	Config Options
        </th>
<th>
        	説明
        </th>
</tr>
<tr>
<td>
        	minHeight
        </td>
<td>
        変更可能最小サイズ(pixel)
        </td>
</tr>
<tr>
<td>
        	maxHeight
        </td>
<td>
        変更可能最大サイズ(pixel)
        </td>
</tr>
</table>
<p />
<div id="attachment_1669" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/09/itm_timetable_paging_frame_size.png"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/09/itm_timetable_paging_frame_size-300x178.png" alt="Grid(時刻表)高さ変更" title="Grid(時刻表)高さ変更" width="300" height="178" class="size-medium wp-image-1669" /></a><p class="wp-caption-text">Grid(時刻表)高さ変更</p></div></p>
<p>Ext.grid.GridPanelのpluginsオプションに指定するだけでこれも簡単に実現できます。</p>
<h3>GridのCell内容をツールチップに表示する</h3>
<p>今回のGrid(時刻表)では問題ないですが、文字列が長すぎてCell内に収まりきらない場合があります。<br />
そのようなときのために、GridのCell上でマウスオーバしたときにツールチップを表示させてみます。</p>
<ul>
<li>（拡張④）GridのCell内容をツールチップに表示する</li>
</ul>
<ul>
<li>grid-timetable.js</li>
</ul>

<div class="wp_codebox"><table width="100%" ><tr id="p142926"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code" id="p1429code26"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">onReady</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    Ext.<span style="color: #660066;">QuickTips</span>.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                                        <span style="color: #009966; font-style: italic;">/* 拡張④ */</span>
&nbsp;
               <span style="color: #006600; font-style: italic;">// ～省略</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> grid <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">grid</span>.<span style="color: #660066;">GridPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
&nbsp;
               <span style="color: #006600; font-style: italic;">// ～省略</span>
&nbsp;
        columns<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'対象空港'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'destination'</span><span style="color: #339933;">,</span>
                renderer<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>v<span style="color: #339933;">,</span> params<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>                 <span style="color: #009966; font-style: italic;">/* 拡張④ ここから */</span>
                    params.<span style="color: #660066;">attr</span> <span style="color: #339933;">=</span> 
                         <span style="color: #3366CC;">'ext:qtitle=&quot;対象空港&quot;'</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' ext:qwidth=&quot;100&quot;'</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' ext:qtip=&quot;'</span> <span style="color: #339933;">+</span> v <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;'</span><span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">return</span> v<span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>                                               <span style="color: #009966; font-style: italic;">/* 拡張④ ここから */</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
               <span style="color: #006600; font-style: italic;">// ～省略</span></pre></td></tr></table></div>

<ul>
<li>拡張④ 3行目<br />
<table class="content" width="100%">
<caption style="text-align: left; "><strong>Ext.QuickTips<strong/></caption>
<tr>
<th width="150">
            Methods
        </th>
<th>
            説明
        </th>
</tr>
<tr>
<td>
            init
        </td>
<td>
全体のQuickTipsのインタフェースを初期化し、QuckTipsを使用可能にします。
        </td>
</tr>
</table>
</li>
<li>拡張④ 16行目～20行目<br />
<table class="content" width="100%">
<caption style="text-align: left; "><strong>Ext.grid.GridPanel<strong/></caption>
<tr>
<th width="150">
        	Config Options
        </th>
<th>
        	説明
        </th>
</tr>
<tr>
<td>
        	renderer
        </td>
<td>
        	セルの与えられたデータ値にHTMLマークアップを生成するために使用される関数です
        </td>
</tr>
</table>
<p>rendererに使用する無名関数function(v, params)で以下のHTML属性を追加することでツールチップ表示が可能になります。</p>
<table class="content" width="100%">
<tr>
<th width="150">
        	属性
        </th>
<th>
        	説明
        </th>
</tr>
<tr>
<td>
ext:qtitle
        </td>
<td>
ツールチップのタイトルです
        </td>
</tr>
<tr>
<td>
ext:qwidth
        </td>
<td>
ツールチップの幅(pixel)です
        </td>
</tr>
<tr>
<td>
ext:qtip
        </td>
<td>
ツールチップで表示する内容です
        </td>
</tr>
</table>
<p>※一般的なHTMLタグに直接上記属性を指定することもできます。
</li>
</ul>
<div id="attachment_1696" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/09/itm_timetable_qtip.png"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/09/itm_timetable_qtip-300x140.png" alt="Grid(時刻表)ツールチップ表示" title="Grid(時刻表)ツールチップ表示" width="300" height="140" class="size-medium wp-image-1696" /></a><p class="wp-caption-text">Grid(時刻表)ツールチップ表示</p></div>
<p>これも簡単に実現できてしまいました。<br />
一般的なHTMLタグにも属性指定して簡単にツールチップを表示できるなんて素敵です。</p>
<h3>最後に</h3>
<p>だいぶん時刻表がカッコ良くなってきました。<br />
ほとんどコードを書くことなく機能が実現できて感動しました。<br />
次回ももう少し時刻表に機能を追加していこうと思っています。<br />
お楽しみに！</p>
<p><a href="http://blog.eni.co.jp/tech/misc/extjs/part2/grid-timetable.html">ExtJS3.0 Gridデモ　「伊丹空港　8月時刻表（全便）　その２」　</a></p>
<h3>参考リンク</h3>
<ul>
<li><a href="http://extjs.com/">Ext</a></li>
<li><a href="http://extjs.co.jp/">Ext Japan</a></li>
<li><a href="http://extjs.com/deploy/dev/examples/samples.html">ExtJS3.0 Samples &#038; Demos</a></li>
<li><a href="http://extjs.com/deploy/dev/docs/">ExtJS API Documentation</a></li>
</ul>
<h3>あわせて読みたい</h3>
<ul>
<li><a href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part1.html">ExtJS3.0でWebアプリケーションのテーブルをリッチにしよう（その１）</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part2.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part2.html" />
	</item>
		<item>
		<title>ExtJS3.0でWebアプリケーションのテーブルをリッチにしよう（その１）</title>
		<link>http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part1.html</link>
		<comments>http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part1.html#comments</comments>
		<pubDate>Wed, 02 Sep 2009 01:14:34 +0000</pubDate>
		<dc:creator>笹山 昭秀</dc:creator>
				<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Ext.grid.GridPanel]]></category>
		<category><![CDATA[ExtJS3.0]]></category>

		<guid isPermaLink="false">http://blog.eni.co.jp/tech/?p=1190</guid>
		<description><![CDATA[こんにちは。笹山です。
WebアプリケーションでDBなどからデータを取得して一覧表示させる方法は、HTMLのTABLEタグで書かれたものが多いと思います。
もちろんスタイルシートを駆使すればカッコよくはなるのでしょうが、今回はこれをもう少し手軽にリッチにしようとExtJSを使ってみました。
余談ですが今回のExtJSサンプルは、私自身の趣味のために作成しました。
趣味でよく伊丹空港に飛行機を撮影に行きます。エアーバンドで便名を聞いて、その飛行機が
「どこ行き？どこから来た？機種は何？」
というのが知りたいことがよくあります。（私だけか？）
これから数回に渡り、ExtJSで伊丹空港の8月の時刻表を私好みにしていこうと思います。

ExtJSとは
インターネットで検索すればすぐに分かると思いますので簡単に紹介します。
まず、ExtJSとは、リッチなWEBアプリケーション開発のためのJavaScriptライブラリです。
コンポーネントも揃っており、拡張も簡単にできます。
また、ドキュメントやサンプルも揃っていますので、比較的簡単にリッチなUIが実現できます。
一般的なテーブル
時刻表をHTMLのTABLEタグで作成するとこんな感じでしょうか。



対象空港
航空会社
便名
機種
伊丹空港時間
対象空港時間
出発/到着種別


札幌（千歳）
JAL
3911
B6
8:00
9:50
Departure


札幌（千歳）
JAL
2001
B7
8:35
10:25
Departure


札幌（千歳）
ANA
771
B6
8:55
10:45
Departure


札幌（千歳）
ANA
775
A32
11:45
13:35
Departure


札幌（千歳）
ANA
777
B6
14:15
16:05
Departure


札幌（千歳）
JAL
2019
CRJ
18:30
20:20
Departure


札幌（千歳）
JAL
2000
CRJ
10:25
8:30
Arrival


札幌（千歳）
JAL
3912
CRJ
13:00
11:05
Arrival


札幌（千歳）
ANA
774
B6
14:15
12:25
Arrival


札幌（千歳）
ANA
776
A32
16:00
14:10
Arrival


札幌（千歳）
JAL
2016
B7
19:25
17:30
Arrival


札幌（千歳）
ANA
778
B6
19:30
17:40
Arrival



一覧の表示だけで何もできません。
例えば、時間の降順に一覧を表示したい場合、プログラムでデータをSortし、その結果で一覧を作成し直す必要があります。
一覧のカラム順番を変えたい場合（例えば、出発/到着種別カラムを一番前のカラムにしたい）、一覧表示後はカラム順番を変えることはできません。
ExtJSを使うと簡単に実現できてしまいます。
ExtJSのインストール

ExtJS3.0をダウンロードして適当な場所に展開します
ExtJSに必要なファイルは以下になります

ext-3.0.0/resources/css/ext-all.css （ExtJSのスタイルシート）
ext-3.0.0/adapter/ext/ext-base.js （ExtJSのcore utilitiesとfunctions）
ext-3.0.0/ext-all.js （ExtJSの全ての機能）
ext-3.0.0/src/locale/ext-lang-ja.js （ExtJSのリソースを日本語化）


ExtJSを使用するHTML（以降grid-timetable.htmlとします）のHEADタグ内に必要なファイルを指定します

1
2
3
  &#60;script type=&#34;text/javascript&#34; src=&#34;path/ext-base.js&#34;&#62;&#60;/script&#62;
  &#60;script type=&#34;text/javascript&#34; src=&#34;path/ext-all.js&#34;&#62;&#60;/script&#62;
  &#60;script type=&#34;text/javascript&#34; src=&#34;path/ext-lang-ja.js&#34; charset=&#34;UTF-8&#34;&#62;&#60;/script&#62;

※linkタグ、scriptタグ中の「path」 : ファイルを配置したディレクトリ名に変更してください

これでExtJSが使用できるようになります。
Ext.grid.GridPanelで時刻表を作成
先ほどのgrid-timetable.htmlに以下を追加します

HEADタグ内にSCRIPTタグを追加して今回ExtJSで作成する外部ファイル（以降 grid-timetable.jsとします）を指定します
BODYタグ内に、DIVタグを追加してidにgrid-timetableを指定し、時刻表を配置する場所を指定します


grid-timetable.html（※linkタグ、scriptタグ中の「path」 : ファイルを配置したディレクトリ名に変更してください）


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
&#60;!DOCTYPE HTML PUBLIC &#34;-//W3C//DTD HTML 4.01 Transitional//EN&#34;
&#34;http://www.w3.org/TR/html4/loose.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62;
    &#60;head&#62;
        &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=utf-8&#34; /&#62;
        &#60;link [...]]]></description>
			<content:encoded><![CDATA[<p>こんにちは。笹山です。</p>
<p>WebアプリケーションでDBなどからデータを取得して一覧表示させる方法は、HTMLのTABLEタグで書かれたものが多いと思います。<br />
もちろんスタイルシートを駆使すればカッコよくはなるのでしょうが、今回はこれをもう少し手軽にリッチにしようとExtJSを使ってみました。</p>
<p>余談ですが今回のExtJSサンプルは、私自身の趣味のために作成しました。<br />
趣味でよく伊丹空港に飛行機を撮影に行きます。エアーバンドで便名を聞いて、その飛行機が<br />
「どこ行き？どこから来た？機種は何？」<br />
というのが知りたいことがよくあります。（私だけか？）<br />
これから数回に渡り、ExtJSで伊丹空港の8月の時刻表を私好みにしていこうと思います。</p>
<p><span id="more-1190"></span></p>
<h3>ExtJSとは</h3>
<p>インターネットで検索すればすぐに分かると思いますので簡単に紹介します。<br />
まず、ExtJSとは、リッチなWEBアプリケーション開発のためのJavaScriptライブラリです。<br />
コンポーネントも揃っており、拡張も簡単にできます。<br />
また、ドキュメントやサンプルも揃っていますので、比較的簡単にリッチなUIが実現できます。</p>
<h3>一般的なテーブル</h3>
<p>時刻表をHTMLのTABLEタグで作成するとこんな感じでしょうか。</p>
<table class="content" border="0">
<tbody>
<tr style="background-color: #deecfd;">
<th>対象空港</th>
<th>航空会社</th>
<th>便名</th>
<th>機種</th>
<th>伊丹空港時間</th>
<th>対象空港時間</th>
<th>出発/到着種別</th>
</tr>
<tr>
<td style="text-align: center">札幌（千歳）</td>
<td style="text-align: center"><span style="color: #cc0000;">JAL</span></td>
<td style="text-align: center">3911</td>
<td style="text-align: center">B6</td>
<td style="text-align: center">8:00</td>
<td style="text-align: center">9:50</td>
<td style="text-align: center">Departure</td>
</tr>
<tr>
<td style="text-align: center">札幌（千歳）</td>
<td style="text-align: center"><span style="color: #cc0000;">JAL</span></td>
<td style="text-align: center">2001</td>
<td style="text-align: center">B7</td>
<td style="text-align: center">8:35</td>
<td style="text-align: center">10:25</td>
<td style="text-align: center">Departure</td>
</tr>
<tr>
<td style="text-align: center">札幌（千歳）</td>
<td style="text-align: center"><span style="color: #003399;">ANA</span></td>
<td style="text-align: center">771</td>
<td style="text-align: center">B6</td>
<td style="text-align: center">8:55</td>
<td style="text-align: center">10:45</td>
<td style="text-align: center">Departure</td>
</tr>
<tr>
<td style="text-align: center">札幌（千歳）</td>
<td style="text-align: center"><span style="color: #003399;">ANA</span></td>
<td style="text-align: center">775</td>
<td style="text-align: center">A32</td>
<td style="text-align: center">11:45</td>
<td style="text-align: center">13:35</td>
<td style="text-align: center">Departure</td>
</tr>
<tr>
<td style="text-align: center">札幌（千歳）</td>
<td style="text-align: center"><span style="color: #003399;">ANA</span></td>
<td style="text-align: center">777</td>
<td style="text-align: center">B6</td>
<td style="text-align: center">14:15</td>
<td style="text-align: center">16:05</td>
<td style="text-align: center">Departure</td>
</tr>
<tr>
<td style="text-align: center">札幌（千歳）</td>
<td style="text-align: center"><span style="color: #cc0000;">JAL</span></td>
<td style="text-align: center">2019</td>
<td style="text-align: center">CRJ</td>
<td style="text-align: center">18:30</td>
<td style="text-align: center">20:20</td>
<td style="text-align: center">Departure</td>
</tr>
<tr>
<td style="text-align: center">札幌（千歳）</td>
<td style="text-align: center"><span style="color: #cc0000;">JAL</span></td>
<td style="text-align: center">2000</td>
<td style="text-align: center">CRJ</td>
<td style="text-align: center">10:25</td>
<td style="text-align: center">8:30</td>
<td style="text-align: center">Arrival</td>
</tr>
<tr>
<td style="text-align: center">札幌（千歳）</td>
<td style="text-align: center"><span style="color: #cc0000;">JAL</span></td>
<td style="text-align: center">3912</td>
<td style="text-align: center">CRJ</td>
<td style="text-align: center">13:00</td>
<td style="text-align: center">11:05</td>
<td style="text-align: center">Arrival</td>
</tr>
<tr>
<td style="text-align: center">札幌（千歳）</td>
<td style="text-align: center"><span style="color: #003399;">ANA</span></td>
<td style="text-align: center">774</td>
<td style="text-align: center">B6</td>
<td style="text-align: center">14:15</td>
<td style="text-align: center">12:25</td>
<td style="text-align: center">Arrival</td>
</tr>
<tr>
<td style="text-align: center">札幌（千歳）</td>
<td style="text-align: center"><span style="color: #003399;">ANA</span></td>
<td style="text-align: center">776</td>
<td style="text-align: center">A32</td>
<td style="text-align: center">16:00</td>
<td style="text-align: center">14:10</td>
<td style="text-align: center">Arrival</td>
</tr>
<tr>
<td style="text-align: center">札幌（千歳）</td>
<td style="text-align: center"><span style="color: #cc0000;">JAL</span></td>
<td style="text-align: center">2016</td>
<td style="text-align: center">B7</td>
<td style="text-align: center">19:25</td>
<td style="text-align: center">17:30</td>
<td style="text-align: center">Arrival</td>
</tr>
<tr>
<td style="text-align: center">札幌（千歳）</td>
<td style="text-align: center"><span style="color: #003399;">ANA</span></td>
<td style="text-align: center">778</td>
<td style="text-align: center">B6</td>
<td style="text-align: center">19:30</td>
<td style="text-align: center">17:40</td>
<td style="text-align: center">Arrival</td>
</tr>
</tbody>
</table>
<p>一覧の表示だけで何もできません。<br />
例えば、時間の降順に一覧を表示したい場合、プログラムでデータをSortし、その結果で一覧を作成し直す必要があります。<br />
一覧のカラム順番を変えたい場合（例えば、出発/到着種別カラムを一番前のカラムにしたい）、一覧表示後はカラム順番を変えることはできません。</p>
<p>ExtJSを使うと簡単に実現できてしまいます。</p>
<h3>ExtJSのインストール</h3>
<ol>
<li><a href="http://extjs.com/products/extjs/download.php">ExtJS3.0をダウンロード</a>して適当な場所に展開します</li>
<li>ExtJSに必要なファイルは以下になります
<ul>
<li>ext-3.0.0/resources/css/ext-all.css （ExtJSのスタイルシート）</li>
<li>ext-3.0.0/adapter/ext/ext-base.js （ExtJSのcore utilitiesとfunctions）</li>
<li>ext-3.0.0/ext-all.js （ExtJSの全ての機能）</li>
<li>ext-3.0.0/src/locale/ext-lang-ja.js （ExtJSのリソースを日本語化）</li>
</ul>
</li>
<li>ExtJSを使用するHTML（以降grid-timetable.htmlとします）のHEADタグ内に必要なファイルを指定します

<div class="wp_codebox"><table width="100%" ><tr id="p119031"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p1190code31"><pre class="html" style="font-family:monospace;">  &lt;script type=&quot;text/javascript&quot; src=&quot;path/ext-base.js&quot;&gt;&lt;/script&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;path/ext-all.js&quot;&gt;&lt;/script&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;path/ext-lang-ja.js&quot; charset=&quot;UTF-8&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<p><span style="color: #ff0000;">※linkタグ、scriptタグ中の「path」 : ファイルを配置したディレクトリ名に変更してください</span></li>
</ol>
<p>これでExtJSが使用できるようになります。</p>
<h3>Ext.grid.GridPanelで時刻表を作成</h3>
<p>先ほどのgrid-timetable.htmlに以下を追加します</p>
<ol>
<li>HEADタグ内にSCRIPTタグを追加して今回ExtJSで作成する外部ファイル（以降 grid-timetable.jsとします）を指定します</li>
<li>BODYタグ内に、DIVタグを追加してidにgrid-timetableを指定し、時刻表を配置する場所を指定します</li>
</ol>
<ul>
<li>grid-timetable.html<span style="color: #ff0000;">（※linkタグ、scriptタグ中の「path」 : ファイルを配置したディレクトリ名に変更してください）</span></li>
</ul>

<div class="wp_codebox"><table width="100%" ><tr id="p119032"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p1190code32"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;
&quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
    &lt;head&gt;
        &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
        &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;path/ext-all.css&quot; /&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;path/ext-base.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;path/ext-all.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;path/ext-lang-ja.js&quot; charset=&quot;UTF-8&quot;&gt;&lt;/script&gt;
&nbsp;
        &lt;script type=&quot;text/javascript&quot; src=&quot;path/grid-timetable.js&quot;&gt;&lt;/script&gt;
        &lt;title&gt;伊丹空港 8月時刻表&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;h1&gt;伊丹空港 8月時刻表&lt;/h1&gt;
        &lt;div id=&quot;grid-timetable&quot;&gt;&lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<table class="content">
<tr>
<th>
        	行番号
        </th>
<th>
        	説明
        </th>
</tr>
<tr>
<td>
        	11行目
        </td>
<td>
        	ExtJSで作成する外部ファイルを指定します
        </td>
</tr>
<tr>
<td>
        	16行目
        </td>
<td>
        	時刻表を配置する場所を指定します
        </td>
</tr>
</table>
<p>　<br />
</p>
<ul>
<li>grid-timetable.js</li>
</ul>

<div class="wp_codebox"><table width="100%" ><tr id="p119033"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
</pre></td><td class="code" id="p1190code33"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">onReady</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> timeTableData <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
        <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'札幌（千歳）'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'JAL'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'3911'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'B6'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 8:00:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 9:50:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Departure'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'札幌（千歳）'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'JAL'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2001'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'B7'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 8:35:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 10:25:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Departure'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'札幌（千歳）'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'ANA'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'771'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'B6'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 8:55:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 10:45:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Departure'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'札幌（千歳）'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'ANA'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'775'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'A32'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 11:45:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 13:35:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Departure'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'札幌（千歳）'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'ANA'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'777'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'B6'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 14:15:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 16:05:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Departure'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'札幌（千歳）'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'JAL'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2019'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'CRJ'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 18:30:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 20:20:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Departure'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'札幌（千歳）'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'JAL'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2000'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'CRJ'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 10:25:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 8:30:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Arrival'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'札幌（千歳）'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'JAL'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'3912'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'B6'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 13:00:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 11:05:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Arrival'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'札幌（千歳）'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'ANA'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'774'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'B6'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 14:15:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 12:25:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Arrival'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'札幌（千歳）'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'ANA'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'776'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'A32'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 16:00:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 14:10:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Arrival'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'札幌（千歳）'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'JAL'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2016'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'B7'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 19:25:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 17:30:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Arrival'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'札幌（千歳）'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'ANA'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'778'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'B6'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 19:30:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'2009/08/01 17:40:00'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'Arrival'</span><span style="color: #009900;">&#93;</span>
    <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> store <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">data</span>.<span style="color: #660066;">ArrayStore</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        fields<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
            <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'destination'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'airline'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'flightName'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'model'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'itamiTime'</span><span style="color: #339933;">,</span> type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'date'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'objectTime'</span><span style="color: #339933;">,</span> type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'date'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'type'</span><span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#93;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> grid <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">grid</span>.<span style="color: #660066;">GridPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        title<span style="color: #339933;">:</span> <span style="color: #3366CC;">'時刻表'</span><span style="color: #339933;">,</span>
        height<span style="color: #339933;">:</span> 320<span style="color: #339933;">,</span>
        width<span style="color: #339933;">:</span> 750<span style="color: #339933;">,</span>
        stripeRows<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        renderTo<span style="color: #339933;">:</span> <span style="color: #3366CC;">'grid-timetable'</span><span style="color: #339933;">,</span>
        store<span style="color: #339933;">:</span> store<span style="color: #339933;">,</span>
        columns<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'対象空港'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'destination'</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'航空会社'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'airline'</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'便名'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'flightName'</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'機種'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'model'</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'伊丹空港時間'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'itamiTime'</span><span style="color: #339933;">,</span>
                renderer<span style="color: #339933;">:</span> Ext.<span style="color: #660066;">util</span>.<span style="color: #660066;">Format</span>.<span style="color: #660066;">dateRenderer</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'H:i'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'対象空港時間'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'objectTime'</span><span style="color: #339933;">,</span>
                renderer<span style="color: #339933;">:</span> Ext.<span style="color: #660066;">util</span>.<span style="color: #660066;">Format</span>.<span style="color: #660066;">dateRenderer</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'H:i'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'出発/到着種別'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'type'</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#93;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    store.<span style="color: #660066;">loadData</span><span style="color: #009900;">&#40;</span>timeTableData<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<table class="content" width="100%">
<caption style="text-align: left; "><strong>Class Ext<strong/></caption>
<tr>
<th width="150">
        	Methods
        </th>
<th>
        	説明
        </th>
</tr>
<tr>
<td>
        	onReady
        </td>
<td>
        	DOMが完全に読みこまれた後に自動的に呼び出され、参照したいページの要素が利用できるようになります
        </td>
</tr>
</table>
<p>　<br />
</p>
<table class="content" width="100%">
<caption style="text-align: left; "><strong>Class Ext.data.ArrayStore（データを保持するためのデータストアを作成します ）<strong/></caption>
<tr>
<th width="150">
        	Config Options
        </th>
<th colspan="2">
        	説明
        </th>
</tr>
<tr>
<td rowspan="4">
        	fields
        </td>
<td colspan="2">
        	データをどのようにマッピングするか定義します
        </td>
</tr>
<tr>
<th width="100">
        	パラメータ
        </th>
<th>
        	説明
        </th>
</tr>
<tr>
<td>
        	name
        </td>
<td>
        	レコード内でfieldを参照する際に用いるnameです<br /> ColumnModelのdataIndexプロパティによって参照されます
        </td>
</tr>
<tr>
<td>
        	type
        </td>
<td>
        	表示できる値に変換するためのデータタイプです<br />指定しない場合は、autoとなり変換を行いません
        </td>
</tr>
<tr>
<th>
        	Methods
        </th>
<th colspan="2">
        	説明
        </th>
</tr>
<tr>
<td>
        	loadData
        </td>
<td colspan="2">
        	データをストアへロードします
        </td>
</tr>
</table>
<p>　<br />
</p>
<table class="content" width="100%">
<caption style="text-align: left; "><strong>Class Ext.grid.GridPanel（Gridパネルを作成します ）<strong/></caption>
<tr>
<th width="150">
        	Config Options
        </th>
<th colspan="2">
        	説明
        </th>
</tr>
<tr>
<td>
        	title
        </td>
<td colspan="2">
        	Gridパネルのタイトルです
        </td>
</tr>
<tr>
<td>
        	height
        </td>
<td colspan="2">
        	Gridパネルの高さ(pixel)です
        </td>
</tr>
<tr>
<td>
        	width
        </td>
<td colspan="2">
        	Gridパネルの幅(pixel)です
        </td>
</tr>
<tr>
<td>
        	stripeRows
        </td>
<td colspan="2">
        	行をストライプ表示します
        </td>
</tr>
<tr>
<td>
        	renderTo
        </td>
<td colspan="2">
        	存在するエレメントIDを指定して、コンテナエレメントへ描画します
        </td>
</tr>
<tr>
<td>
        	store
        </td>
<td colspan="2">
        	Gridがデータストアとして扱うストアを指定します
        </td>
</tr>
<tr>
<td rowspan="6">
        	columns
        </td>
<td colspan="2">
        	Gridが使うColumnModelを定義します
        </td>
</tr>
<tr>
<th width="100">
        	パラメータ
        </th>
<th>
        	説明
        </th>
</tr>
<tr>
<td>
        	header
        </td>
<td>
        	ヘッダーテキストです
        </td>
</tr>
<tr>
<td>
        	sortable
        </td>
<td>
        	カラムソートを許可します
        </td>
</tr>
<tr>
<td>
        	dataIndex
        </td>
<td>
        	Gridのデータストアで定義したnameを指定します
        </td>
</tr>
<tr>
<td>
        	renderer
        </td>
<td>
        	セルの与えられたデータ値にHTMLマークアップを生成するために使用される関数です
        </td>
</tr>
</table>
<p>これをブラウザで表示すると、ソート、カラム移動、カラム幅の変更が可能な時刻表が表示されるはずです。<br />
今回はあらかじめ用意しておいた配列でExt.data.ArrayStoreを用いてGridを作成しました。DBからデータを取得してGridを作成するにはJSON形式でレスポンスを返し、Ext.data.JsonStoreを使用してGridを作成します。</p>
<div id="attachment_1377" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/08/itm_timetable_sort.png"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/08/itm_timetable_sort-300x128.png" alt="ExtJS Gridのカラムソート" title="ExtJS Gridのカラムソート" width="300" height="128" class="size-medium wp-image-1377" /></a><p class="wp-caption-text">ExtJS Gridのカラムソート</p></div><br /><div id="attachment_1378" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/08/itm_timetable_clm_dragdrop.png"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/08/itm_timetable_clm_dragdrop-300x129.png" alt="ExtJS Gridのカラム移動" title="ExtJS Gridのカラム移動" width="300" height="129" class="size-medium wp-image-1378" /></a><p class="wp-caption-text">ExtJS Gridのカラム移動</p></div>
<h3>もう少しリッチに</h3>
<p>「シンプルGrid」で今回のブログを終わろうと思いましたが、もう少しお付き合いください。</p>
<p>あと３点追加したいと思います。</p>
<ul>
<li>（追加機能①）　伊丹空港の時刻表なので伊丹空港時間で最初から昇順表示しておく</li>
<li>（追加機能②）　Gridへ自動的に行番号を振る</li>
<li>（追加機能③）　航空会社ごとに色づけして表示</li>
</ul>
<p>先ほどのgrid-timetable.jsに以下を追加してください。</p>
<ul>
<li>追加機能①　28行目～31行目<br />
<table class="content" width="100%">
<caption style="text-align: left; "><strong>Ext.data.ArrayStore<strong/></caption>
<tr>
<th width="150">
        	Config Options
        </th>
<th colspan="2">
        	説明
        </th>
</tr>
<tr>
<td rowspan="4">
        	sortInfo
        </td>
<td colspan="2">
        	ソート順序を指定します
        </td>
</tr>
<tr>
<th width="100">
        	パラメータ
        </th>
<th>
        	説明
        </th>
</tr>
<tr>
<td>
        	field
        </td>
<td>
        	ソートを行う対象fieldを指定します
        </td>
</tr>
<tr>
<td>
        	direction
        </td>
<td>
        	ソート方向を指定します
        </td>
</tr>
</table>
</li>
<li>追加機能②　42行目<br />
<table class="content" width="100%">
<caption style="text-align: left; "><strong>Ext.grid.RowNumberer<strong/></caption>
<tr>
<th width="150">
        	Config Options
        </th>
<th colspan="2">
        	説明
        </th>
</tr>
<tr>
<td>
－
        </td>
<td colspan="2">
        	自動的にGridに行番号を表示します
        </td>
</tr>
</table>
</li>
<li>追加機能③　52行目～62行目<br />
<table class="content" width="100%">
<caption style="text-align: left; "><strong>Ext.grid.GridPanel<strong/></caption>
<tr>
<th width="150">
        	Config Options
        </th>
<th>
        	説明
        </th>
</tr>
<tr>
<td>
renderer
        </td>
<td>
セルの与えられたデータ値にHTMLマークアップを生成するために使用される関数です<br />
			文字列を比較して文字色を変えています
        </td>
</tr>
</table>
</li>
</ul>
<p></p>

<div class="wp_codebox"><table width="100%" ><tr id="p119034"><td class="line_numbers"><pre>15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
</pre></td><td class="code" id="p1190code34"><pre class="javascript" style="font-family:monospace;">&nbsp;
   ～ 省略 ～
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> store <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">data</span>.<span style="color: #660066;">ArrayStore</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        fields<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
            <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'destination'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'airline'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'flightName'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'model'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'itamiTime'</span><span style="color: #339933;">,</span> type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'date'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'objectTime'</span><span style="color: #339933;">,</span> type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'date'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'type'</span><span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        sortInfo<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>                              <span style="color: #009966; font-style: italic;">/* 追加機能 ① ここから */</span>
           field<span style="color: #339933;">:</span> <span style="color: #3366CC;">'itamiTime'</span><span style="color: #339933;">,</span>
           direction<span style="color: #339933;">:</span> <span style="color: #3366CC;">'ASC'</span>
        <span style="color: #009900;">&#125;</span>                                        <span style="color: #009966; font-style: italic;">/* 追加機能 ① ここまで */</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> grid <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">grid</span>.<span style="color: #660066;">GridPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        title<span style="color: #339933;">:</span> <span style="color: #3366CC;">'時刻表'</span><span style="color: #339933;">,</span>
        height<span style="color: #339933;">:</span> 320<span style="color: #339933;">,</span>
        width<span style="color: #339933;">:</span> 750<span style="color: #339933;">,</span>
        stripeRows<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        renderTo<span style="color: #339933;">:</span> <span style="color: #3366CC;">'grid-timetable'</span><span style="color: #339933;">,</span>
        store<span style="color: #339933;">:</span> store<span style="color: #339933;">,</span>
        columns<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
            <span style="color: #003366; font-weight: bold;">new</span> Ext.<span style="color: #660066;">grid</span>.<span style="color: #660066;">RowNumberer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>         <span style="color: #009966; font-style: italic;">/* 追加機能 ② */</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'対象空港'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'destination'</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#123;</span>
                header<span style="color: #339933;">:</span> <span style="color: #3366CC;">'航空会社'</span><span style="color: #339933;">,</span>
                sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
                dataIndex<span style="color: #339933;">:</span> <span style="color: #3366CC;">'airline'</span>
                renderer<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>v<span style="color: #339933;">,</span> params<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>  <span style="color: #009966; font-style: italic;">/* 追加機能 ③ ここから */</span>
                    <span style="color: #003366; font-weight: bold;">var</span> airlineColor <span style="color: #339933;">=</span> v<span style="color: #339933;">;</span>
                        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>v <span style="color: #339933;">==</span> <span style="color: #3366CC;">'ANA'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                            airlineColor <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;span style=&quot;color: #003399;&quot;&gt;'</span> <span style="color: #339933;">+</span> v <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>v <span style="color: #339933;">==</span> <span style="color: #3366CC;">'JAL'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                            airlineColor <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;span style=&quot;color: #cc0000;&quot;&gt;'</span> <span style="color: #339933;">+</span> v <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                            <span style="color: #006600; font-style: italic;">// 何もしない</span>
                        <span style="color: #009900;">&#125;</span>
                        <span style="color: #000066; font-weight: bold;">return</span> airlineColor<span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>                                 <span style="color: #009966; font-style: italic;">/* 追加機能 ③ ここまで */</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
   ～ 省略 ～</pre></td></tr></table></div>

<div id="attachment_1404" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.eni.co.jp/tech/wp-content/uploads/2009/08/itm_timetable_no_col.png"><img src="http://blog.eni.co.jp/tech/wp-content/uploads/2009/08/itm_timetable_no_col-300x129.png" alt="時刻表 機能追加" title="時刻表 機能追加" width="300" height="129" class="size-medium wp-image-1404" /></a><p class="wp-caption-text">時刻表 機能追加</p></div>
<p><a href="http://blog.eni.co.jp/tech/misc/extjs/part1/grid-timetable.html">ExtJS3.0 Gridデモ　「伊丹空港　8月時刻表（全便）」</a></p>
<h3>最後に</h3>
<p>今回はExtJSのGridでシンプルな時刻表を作りました。<br />
難しいことをコーディングしなくても簡単に実現できることがお分かりいただけたと思います。<br />
次回もまだまだ機能追加していきます。お楽しみに！</p>
<h3>参考リンク</h3>
<ul>
<li><a href="http://extjs.com/">Ext</a></li>
<li><a href="http://extjs.co.jp/">Ext Japan</a></li>
<li><a href="http://extjs.com/deploy/dev/examples/samples.html">ExtJS3.0 Samples &#038; Demos</a></li>
<li><a href="http://extjs.com/deploy/dev/docs/">ExtJS API Documentation</a></li>
</ul>
<h3>あわせて読みたい</h3>
<ul>
<li><a href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part2.html">ExtJS3.0でWebアプリケーションのテーブルをリッチにしよう（その２）</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part1.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.eni.co.jp/tech/2009/09/extjs3_grid_table_part1.html" />
	</item>
	</channel>
</rss>
