Yui is a powerful JS framework, can be a good implementation of the Dynamic table page function, and can be implemented across browsers, development without considering different browser problems.
This example is YUI to achieve a simple example of the table, this example is based on the example provided by Yui, adding a column of hidden and custom hyperlinks.
File introduced:
<link rel= "stylesheet" type= text/css "href=". /public/css/yui/fonts-min.css "mce_href=" Public/css/yui/fonts-min.css "/> <link rel=" stylesheet "type=" text/ CSS "href=". /public/css/yui/datatable.css "mce_href=" Public/css/yui/datatable.css "/> <mce:script type=" Text/javascript " Src= ". /public/js/yui/yahoo-dom-event.js "mce_src=" Public/js/yui/yahoo-dom-event.js "></mce:script> <mce: Script type= "Text/javascript" src= ". /public/js/yui/dragdrop-min.js "mce_src=" Public/js/yui/dragdrop-min.js "></mce:script> <mce:script Type= "Text/javascript" src= ". /public/js/yui/element-min.js "mce_src=" public/js/yui/element-min.js "></mce:script> <mce:script type= "Text/javascript" src= ". /public/js/yui/datasource-min.js "mce_src=" Public/js/yui/datasource-min.js "></mce:script> <mce: Script type= "Text/javascript" src= ". /public/js/yui/datatable-min.js "mce_src=" Public/js/yui/datatable-min.js "></mce:script>
Style:
<mce:style type= "Text/css" ><!--body {margin:0; padding:0;} yui-skin-sam. yui-dt-liner {white-space:nowrap; }--></mce:style><style type= "Text/css" mce_bogus= "1" >body {margin:0; padding:0;} yui-skin-sam. Yui-dt-liner {white-space:nowrap;} </style>
Data Source:
YAHOO.example.Data = {bookorders: [{ID: "po-0167", Date:new Date (1980, 2,), Quantity:1, Amount:4, title: "A book about Nothing '}, {id: "po-0783", Date:new date ("January 3, 1983"), Quantity:null, amount:12.12345, title: "The Meaning of Life"}, {ID: "po-0297", Date:new date (1978, one), Quantity:12, amount:1.25, title: "This book is meant to be Read Aloud"}, {ID: "po-1482", Date:new date ("March, 1985"), Quantity:6, amount:3.5, title: "Read Me Twice"}]}
Form implementation code:
YAHOO.util.Event.addListener (window, "Load", function () {YAHOO.example.Basic = function () {var insertlink=function ( Elcell, Orecord, Ocolumn, oData) {elcell.innerhtml= "<a href=" http://www.csdn.net?id= "+orecord.getdata (" id ") +" " mce_href= "http://www.baidu.com?id=" +orecord.getdata ("id") + ">" +odata+ "</a>"; var mycolumndefs = [{key: ' id ', Hidden:true,sortable:true, Resizeable:true,formatter:insertlink}, {key: ' Date ', Formatter:insertlink}, {key: "Quantity", Formatter:YAHOO.widget.DataTable.formatNumber, Sortable:true, resizeable: True}, {key: "Amount", Formatter:YAHOO.widget.DataTable.formatCurrency, Sortable:true, resizeable:true}, {key: "title ", Sortable:true, resizeable:true}]; var mydatasource = new YAHOO.util.DataSource (YAHOO.example.Data.bookorders); Mydatasource.responsetype = YAHOO.util.DataSource.TYPE_JSARRAY; Mydatasource.responseschema = {fields: ["id", "date", "Quantity", "Amount", "title"]}; var mydatatable = new YAHOO.widget.DataTable ("Yuitable", Mycolumndefs, MydatasOurce, {caption: "DataTable caption"}); return {ods:mydatasource, odt:mydatatable}; }(); });
Page implementation:
<body class= "Yui-skin-sam" > <div id= "yuitable" ></div> </body>