为什么YUI 2 DataTables不能在IE中工作但是在FireFox中工作?

时间:2011-10-20 19:20:11

标签: javascript internet-explorer yui datatables

所以我使用YUI 2数据表小部件和tabview组件来显示多个查询的结果,这些查询全部同时执行,在单独的选项卡中包含漂亮,样式化和可排序的表。在FireFox中运行得很好。在IE中,它只是在一个简单的HTML表标记中显示数据,该标记是使用PHP生成的服务器端,实际上它充当数据表小部件的DataSource。我的所有HTML都是生成服务器端的。这是我的剧本:

<script type="text/javascript">
  YAHOO.util.Event.onContentReady("ready14", function() {
 //Sets globals

 var dataSource= YAHOO.util.DataSource;
 var getIt = YAHOO.util.Dom.get;
 var dataType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
 var table =  YAHOO.widget.DataTable;
 var scroll = YAHOO.widget.ScrollingDataTable;
 var numbers= YAHOO.widget.DataTable.formatNumber;
 var strings = YAHOO.widget.DataTable.formatString;
 var dates = YAHOO.widget.DataTable.formatDate;

 var niceTables = function() {


            var myTabView = new YAHOO.widget.TabView("reportTables");
        var myColumnDefs =[
            {key:"Tactic",formatter:strings,sortable:true},
            {key:"Opt-In Count",formatter:numbers,sortable:true,        sortOptions:     defaultDir: table.CLASS_DESC }},
        ];
         var myColumnDefs2 =[
            {key:"Tactic",formatter:strings,sortable:true},
            {key:"Opt-In Count",formatter:numbers,sortable:true, sortOptions: { defaultDir: table.CLASS_DESC }},
        ];
        var myColumnDefs3 =[
            {key:"Lead Meta Data ID" },{key:"First Name",formatter:strings,sortable:true},{key:"Last Name",formatter:strings,sortable:true},{key:"Address"}, {key:"City",formatter:strings,sortable:true},{key:"State",formatter:strings,sortable:true},{key:"Zip",formatter:strings,sortable:true}, {key:"Email"},{key:"Phone"}, {key:"Gender",formatter:strings,sortable:true},
            {key:"DOB",formatter:dates,sortable:true},{key:"Lead Type",formatter:strings,sortable:true}, {key:"Lead Source"},{key:"LOB",formatter:strings,sortable:true},{key:"Client",formatter:strings,sortable:true},{key:"Rep Nbr",formatter:strings,sortable:true, sortOptions: { defaultDir: YAHOO.widget.DataTable.CLASS_DESC }},{key:"Duplicate",formatter:strings,sortable:true},{key:"Comments"}, {key:"Social Media Source",formatter:strings,sortable:true},{key:"Lead Ready",formatter:dates,sortable:true,},{key:"Lead Sent",formatter:dates,sortable:true, sortOptions: { defaultDir: YAHOO.widget.DataTable.CLASS_DESC }},{key:"Tactic Name",formatter:strings,sortable:true},{key:"Tactic Line Of Business ",formatter:strings,sortable:true},
        ];

                    var myColumnDefs4 =[
            {key:"Prize Type",formatter:strings,sortable:true },{key:"First Name",formatter:strings,sortable:true},{key:"Last Name",formatter:strings,sortable:true},{key:"Address"},{key:"City", sortable:true}, {key:"State",formatter:strings,sortable:true},{key:"Zip",formatter:strings,sortable:true},{key:"Email"}, {key:"Phone"}, {key:"Play Date",formatter:dates,sortable:true, sortOptions: { defaultDir:table.CLASS_DESC }},
           ];
        var myColumnDefs5 =[
            {key:"Prize Type",formatter:strings,sortable:true },
            {key:"Prize Type Count",formatter:numbers,sortable:true, sortOptions: { defaultDir: table.CLASS_DESC }},
        ];
        var myColumnDefs6 =[
            {key:"Lead Source",formatter:strings,sortable:true},
            {key:"Dupe Count",formatter:numbers,sortable:true, sortOptions: { defaultDir:table.CLASS_DESC }},
        ];
        var myColumnDefs7 =[
            {key:"Guitar Type",formatter:strings,sortable:true },
            {key:"Count",formatter:numbers,sortable:true, sortOptions: { defaultDir: table.CLASS_DESC }},
        ];
        var myColumnDefs8 =[
            {key:"Tactic",formatter:strings,sortable:true },
            {key:"Opt-In Count",formatter:numbers,sortable:true, sortOptions: { defaultDir: table.CLASS_DESC }},
        ];
        var myColumnDefs9 =[
            {key:"Tactic",formatter:strings,sortable:true },
            {key:"Opt-In Count",formatter:numbers,sortable:true, sortOptions: { defaultDir: table.CLASS_DESC }},
        ];
                    var myColumnDefs10 =[
            {key:"Concert ID" },{key:"Artist" },{key:"Concert City" },{key:"Concert State" },{key:"Concert Date" },{key:"Entry Deadline" },{key:"Lead Meta Data ID" }, {key:"First Name"},
             {key:"Last Name"}, {key:"Address"},{key:"City"},{key:"State"},{key:"Zip"},{key:"Email"},{key:"Phone"},{key:"Lead Type"},{key:"Lead Source"},   {key:"LOB"},{key:"Client"},{key:"Rep Nbr"}, {key:"Duplicate"},,
        ];

        //get the YUI DataSource for each table
        var myDataSource =  new dataSource(getIt("optins"));
        myDataSource.responseType = dataType;
        myDataSource.responseSchema = {
            fields: ["Tactic","Opt-In Count"]
        };
        var myDataSource2 =  new dataSource(getIt("optTotal"));
        myDataSource2.responseType = dataType;
        myDataSource2.responseSchema = {
            fields: ["Tactic","Opt-In Count"]
        };
        var myDataSource3 =  new dataSource(getIt("optInReport"));
        myDataSource3.responseType = dataType;
        myDataSource3.responseSchema = {
            fields: ["Lead Meta Data ID","First Name","Last Name","Address","City","State","Zip","Email","Phone",
                    "Gender","DOB","Lead Type","Lead Source","LOB","Client","Rep Nbr","Duplicate","Comments","Social Media Source","Lead Ready","Lead Sent","Tactic Name","Tactic Line Of Business",]
        };
        var myDataSource4 =  new dataSource(getIt("spinWinners"));
        myDataSource4.responseType = dataType;
        myDataSource4.responseSchema = {
            fields: ["Prize Type","Band","First Name","Last Name","Address","City","State","Zip","Email","Phone","Play Date",]
        };
         var  myDataSource5 =  new dataSource(getIt("prizes"));
         myDataSource5.responseType = dataType;
         myDataSource5.responseSchema = {
            fields: ["Prize Type","Prize Type Count"]
        };
         var  myDataSource6 =  new dataSource(getIt("dupeCount"));
        myDataSource6.responseType = dataType;
        myDataSource6.responseSchema = {
            fields: ["Lead Source","Dupe Count"]
        };
         var myDataSource7 =  new dataSource(getIt("guitarType"));
        myDataSource7.responseType = dataType;
        myDataSource7.responseSchema = {
            fields: ["Guitar Type","Count"]
        };
         var myDataSource8 =  new dataSource(getIt("guitarTactic"));
        myDataSource8.responseType = dataType;
        myDataSource8.responseSchema = {
            fields: ["Tactic","Opt-In Count"]
        };
        var myDataSource9 =  new dataSource(getIt("OptInsSent"));
        myDataSource9.responseType = dataType;
        myDataSource9.responseSchema = {
            fields: ["Tactic","Opt-In Count"]
        };
          var myDataSource10 =  new dataSource(getIt("ticketEntries"));
       myDataSource10.responseType = dataType;
       myDataSource10.responseSchema = {
           fields: ["Concert ID","Artist","Concert City","Concert State","Concert Date","Entry Deadline","Lead Meta Data ID","First Name","Last Name","Address","City","State","Zip","Email","Phone",
                 "Lead Type","Lead Source","LOB","Client","Rep Nbr","Duplicate",]
        };


                        new table("table1", myColumnDefs, myDataSource);            
                        new table("table3", myColumnDefs2, myDataSource2);          
                        new scroll("table4", myColumnDefs3, myDataSource3,{width:"118em", height:"53em"});          
                        new table("table6", myColumnDefs4, myDataSource4);          
                        new table("table7", myColumnDefs5,  myDataSource5);         
                        new table("table8", myColumnDefs6, myDataSource6);          
                        new table("table10", myColumnDefs7, myDataSource7);
                        new table("table11", myColumnDefs8, myDataSource8);         
                        new table("table12", myColumnDefs9, myDataSource9);                       
                        new scroll("table13", myColumnDefs10, myDataSource10,{width:"118em", height:"53em"});
            }();











        return {

        };

});

1 个答案:

答案 0 :(得分:5)

您的对象/数组中有逗号逗号。 IE在尾随逗号上窒息。

var breaksIE = ['trailing', 'comma', '=>', ]; // boom