この人の作品は実はあまり好きでなかったのですが、この作品はとても良かったです。
張作霖爆殺事件、言葉だけは昔歴史で習って知ってはいましたが、張作霖が何者なのかは全く知りませんでした。
う〜ん、ちょっと興味湧いてきた。
![]() |
【内容説明】 |
試合はRuby,勝負はC#!
![]() |
【内容説明】 |
これは、tableやth要素にclass属性でtable-autofilterとかtable-filterableとしてあげるだけで, ソートやらフィルタリングやらページングやら(いずれもクライアント側で処理)を簡単に装備できてしまうという超スグレモノです。
早速やってみる。
まずソースをダウンロードして、とりあえず table.js という名前で保存してインクルード。JavaScriptに関してはこれだけで、自分でなにか書く必要とかはありません。
<%= javascript_include_tag "table.js" %>
次に、フィルタリングしたいテーブルのclass属性に class="table-autofilter" を追加して、フィルタしたい列のthに class="table-filterable"を指定。
こんな感じでしょうか、、。
<table class="table-autofilter"> <thead> <th class="table-filterable">文字列</th>
※テーブルヘッダは thead, データ行は tbodyに書かないとダメなようです。JavaScriptソース見たらそうなってました、、、。
適当にデータを作って、ページを表示してみる。
public class Main { public static void main(String[] args){ try { InputStream file = new FileInputStream("data/hello_poi.xls"); Workbook book = new HSSFWorkbook(file); FormulaEvaluator feval = book.getCreationHelper().createFormulaEvaluator(); Sheet sheet = book.getSheetAt(0); for(int rowIndex = 0; rowIndex < 4; rowIndex++) { Row row = sheet.getRow(rowIndex); for (int colIndex = 0; colIndex < 2; colIndex++) { Cell cell = row.getCell(colIndex); String rawValue = cell.toString(); feval.evaluateInCell(cell); System.out.printf("row=%d, cell=%d, rawValue=%s, evaluatedValue=%s\n" , rowIndex, colIndex, rawValue, cell); } } file.close(); } catch (Exception e) { e.printStackTrace(); } } }
先日Rails3では routes.rbが下記のようになっていてRestfullな物しか呼べないようになっていますが、正直アクション名とか自由に使いたいので、コメント外して使えるようにしました。
# This is a legacy wild controller route that's not recommended for RESTful applications. # Note: This route will make all actions in every controller accessible via GET requests. # match ':controller(/:action(/:id(.:format)))'
ただ、それだけの話しです、、、。
さとやn
C#が好きだけど仕事はRubyばかりな開発者。
最近はDockerとか関数型言語とかAngularJSにハマっている。
武蔵小杉とか田町とか柏とかに出没。