ã¯ããã«
ãä»åã¯ããã¼ãã«ã®è¦æ ããè¯ãããããæ§ã ãªæ©è½ãç°¡åã«è¿½å ãããã§ããjQueryãã©ã°ã¤ã³ã解説ãã¾ãï¼è¡¨1ï¼ã
åå | æ¦è¦ |
jquery.columnfilters | 表ã«æ¤ç´¢ç¨ãã©ã¼ã ãè¨ãã¦ããã©ã¼ã ã«æåãæ°åãå ¥ããã¨ç¹å®ã®è¡ã®ã¿è¡¨ç¤ºã§ãã |
jquery.csv2table.js | csvãã¡ã¤ã«ãèªã¿è¾¼ã¿HTMLã®ãã¼ãã«ã«å¤æã§ããã½ã¼ããçè²ãªã©ãã§ãã |
tableHover | 表ã«ã«ã¼ã½ã«ãéãããã¯ãªãã¯ãããããéãè¡ãåã®è²ãå¤ãããã |
対象èªè
- jQueryãã©ã°ã¤ã³ã«èå³ãããã使ã£ã¦ã¿ããæ¹
å¿ è¦ãªç°å¢ã¨æºå
ãå·çæç¹ã®jQueryã®ææ°çã¯ã1.7.2ã§ãã第1åãåèã«ããã¦ã³ãã¼ããã¦ãã ãããã¾ããjQueryãã©ã°ã¤ã³ã®åºæ¬çãªä½¿ãæ¹ã¯ã第3åãåç §ãã¦ãã ããã
ããµã³ãã«ã§ã¯ãhtmlãã¡ã¤ã«ã¨åãé層ã«ãpluginsãã¨ãããã©ã«ããä½æãã使ç¨ãããã©ã°ã¤ã³é¢é£ã®ãã¡ã¤ã«ã¯ããã«ã¾ã¨ãã¦é ç½®ãã説æãé²ãã¾ããã¾ããscriptsãã©ã«ãã«ã¯jQueryæ¬ä½ãé ç½®ãã¦ããã¾ãããªããä»åç´¹ä»ãããjquery.csv2table.jsããã©ã°ã¤ã³ã¯ãimgããã©ã«ãå ã®gifãã¡ã¤ã«ããdataããã©ã«ãå ã®csvãã¡ã¤ã«ãèªã¿è¾¼ãè¨å®ã®ããããimgããã©ã«ããè¨ãã¦ããã«gifãã¡ã¤ã«ãããdataããã©ã«ããè¨ãã¦ããã«csvãã¡ã¤ã«ãé ç½®ãã¦ããã¾ãã
ãã£ã«ã¿æ©è½ä»ããã¼ãã«ãä½æãã - jquery.columnfiltersãã©ã°ã¤ã³
ãjquery.columnfiltersãã©ã°ã¤ã³ã¯ã表ã«æ¤ç´¢ç¨ã®ãã©ã¼ã ãè¨ãã¦ããã©ã¼ã ã«æåãæ°åãå ¥ããã¨ããã®æåï¼æ°åããå§ã¾ãç¹å®ã®åã®ã¿ã表示ã§ãããã©ã°ã¤ã³ã§ãã表ã«ãã©ã¼ã ã表示ããã¦ããç¶æ ãå³1ã«ç¤ºãã¾ãã
jquery.columnfiltersãã©ã°ã¤ã³ã使ã£ããµã³ãã«ã®å®è¡ä¾
ãç¶ãã¦ãã©ã¼ã ã«æåãå ¥ãã¦ããã®æåããå§ã¾ãè¡ã®ã¿ã表示ããç¶æ ãå³2ã«ç¤ºãã¾ããAã®é ç®ã§Sããå§ã¾ãè¨èãããè¡ã®ã¿ã表示ããã¦ãããã¨ãåããã¾ãã
ãã¾ããæ¤ç´¢ã®éã«ã¯ã*ããã¯ã¤ã«ãã«ã¼ãã¨ãã¦æ©è½ããããã¨ãã§ãã¾ããDã®é ç®ã§0ãå«ãæ°åãããè¡ã®ã¿ã表示ããç¶æ ãå³3ã«ç¤ºãã¾ãã
jquery.columnfiltersãã©ã°ã¤ã³ã®ä½¿ãæ¹
ã使ç¨æ¹æ³ã¯ãjquery.columnfiltersãã©ã°ã¤ã³ã®ãµã¤ãä¸ã®ãDownload the sourceããããcolumnfilters.zipãã¨ãããã¡ã¤ã«ããã¦ã³ãã¼ããã¦ä¿åãã解åå¾ãã½ã¼ã¹ãã¼ã¿ãjquery.columnfilters.jsãããpluginsããã©ã«ãä¸ã«é ç½®ãã¾ãã
ããªã¹ã1ã«jquery.columnfiltersãã©ã°ã¤ã³ã®ä½¿ç¨ä¾ã示ãã¾ãã
<!DOCTYPE html> <html> <head> <meta charset=UTF-8" /> <title>jQueryãã©ã°ã¤ã³ï¼jquery.columnfilters.js) ãµã³ãã«</title> <!--1.jQueryã®èªã¿è¾¼ã¿--> <script type="text/javascript" src="./Scripts/jquery-1.7.2.min.js"></script> <!--2.ãã©ã°ã¤ã³ã®èªã¿è¾¼ã¿--> <script type="text/javascript" src="./plugins/jquery.columnfilters.js" charset="utf-8"></script> <!--3.ãã©ã°ã¤ã³ã®è¨å®--> <script type="text/javascript"> $(document).ready(function(){ $('table#book1').columnFilters({alternateRowClassNames:['rowa','rowb'] }); }); </script> <!--4.CSSã®è¨å®--> <style type="text/css"> thead{background-color: #bbb;} table{background-color: #DCDCDC;} td{text-align:center;} table tr.rowb{background-color:#EAf2FD;} table tr.filterColumns td{padding:2px;} body{padding-bottom:150px;} </style> </head> <body> <h1>jQueryãã©ã°ã¤ã³ï¼jquery.columnfilters.js) ãµã³ãã«</h1> <!--5.ãã¼ãã«ã®è¨å®--> <table id="book1"> <thead> <tr><th>No.</th><th>A</th><th>B</th><th>C</th> </thead> <tbody> <tr><td>1</td><td>Yamada</td><td>abc</td><td>012</td> <tr><td>2</td><td>Suzuki</td><td>cba</td><td>345</td> <tr><td>3</td><td>Tanaka</td><td>xyz</td><td>678</td> <tr><td>4</td><td>Sasaki</td><td>zyx</td><td>901</td> </tbody> </table> </body> </html>
ãã3.ãã©ã°ã¤ã³ã®è¨å®ãã§ã¯ãã$(document).ready(function(){});ãã®ä¸ã§jQueryã¡ã½ããã¨ãã¦jquery.columnfiltersãã©ã°ã¤ã³ãæ©è½ããã¾ããã»ã¬ã¯ã¿ã¼é¨åã«ãtable#idåãã¨ãã£ãå½¢ã§ãã¼ãã«ã®idåï¼ãã®ã¹ã¯ãªããã§ã¯book1ï¼ãè¨å®ãããã¨ãéè¦ã§ããããã¦ãã¡ã½ããé¨åã«ãcolumnFiltersããè¨å®ãã¦ãã¾ãã
ããã®ã¹ã¯ãªããã§ã¯è¡ãã¨ãéãè²ã«è¦ãããããã.columnFilters();ãã®æ¬å¼§å ã«ã{alternateRowClassNames:['rowa','rowb']}ãã¨è¨è¿°ããå¥æ°è¡ããrowaããå¶æ°è¡ããrowbãã¨è¨å®ãããã®å¾ã®ã4.cssã®è¨å®ãã§ãrowbãã®è²ãå¥ã«è¨å®ãã¦ãã¾ããè¨å®ãªãã·ã§ã³ã®ä¸ã¤ã§ãããalternateRowClassNamesãã«ã¤ãã¦ã¯å¾è¿°ãã¾ãã
ããã¨ã¯ããã®ãã©ã°ã¤ã³ãæ©è½ãããã表ã«ã3.ãã©ã°ã¤ã³ã®è¨å®ãã§è¨å®ããidåãä»ä¸ããã ãã§ãæ¤ç´¢çªä»ãã®è¡¨ãå®æãã¾ãã
ãªãã·ã§ã³ã«ããæ§ã ãªæ¤ç´¢
ãæ¤ç´¢ãªãã·ã§ã³ã¨ãã¦ã¯ä»¥ä¸ã®ãã®ãããã¾ãã
æ¤ç´¢çªã«å ¥ããè¨å· | åå | æ¦è¦ |
* | wildcard | *ã®å¾ã«å ¥åããæåãå«ãè¡ã®ã¿ã表示ï¼é常ã®å ´åæåãå ¥åããã¨ããã®æåããå§ã¾ãè¡ã®ã¿ãè¡¨ç¤ºï¼ |
! | notcharacter | !ã®å¾ã«å ¥åããæåããå§ã¾ããªãè¡ã®ã¿ã表示 |
ããããã®æ¤ç´¢ãªãã·ã§ã³ã¯ã.columnFilter();ãã®æ¬å¼§å ã§
$(document).ready(function() { $('table#idå').columnFilters({wildCard:'#',notCharacter:'?'}); });
ãã¨è¨å®ããã¨ãwildcardã¨ãã¦ä½¿ç¨ããæåã*ãã#ã«ãnotcharacterã§ä½¿ç¨ããæåã!ãã?ã«ãã¨ãã£ãå½¢ã§å¤æ´ã§ãã¾ãã
å¤å½©ãªè¨å®ãªãã·ã§ã³
ãã¾ããæ§ã ãªè¨å®ãªãã·ã§ã³ãç¨æããã¦ãã¾ãã
ãªãã·ã§ã³å | æ¢å®å¤ | æ¦è¦ |
caseSensitive | false | 大æåã»å°æåãåºå¥ããã |
minSearchCharacters | 1 | ä½æåå ¥åããããæ¤ç´¢ãå®æ½ããã |
excludeColumns | [] | æ¤ç´¢çªãè¨ããªãåï¼åçªå·ãé åã§æå®ï¼ |
alternateRowClassNames | [] | 交äºã®è¡ã«ã¹ã¿ã¤ã«ã¯ã©ã¹ãå²ãå½ã¦ãï¼ä»»æã®ã¹ã¿ã¤ã«ã¯ã©ã¹ãè¨å®å¯è½ï¼ |
ãããããä¾ãã°caseSensitiveãtrueã«ãã¦å¤§æåã»å°æåã¾ã§æ£ç¢ºã«å ¥åãä¿ãå ´åã¯ã.columnFilters();ãã®æ¬å¼§å ã§å¤æ´å¯è½ã§ããã以ä¸ã®ããã«å¤æ´ãã¾ãã
$(document).ready(function() { $('table#idå').columnFilters({ caseSensitive:true }); });