2013-10-31 48 views
1

我仍然要在本地主機上通過Web服務器嘗試它,但我認爲問題可能在其他地方。設置sSwfPath未在初始化中設置

我正在使用DataTables開發ASP.NET MVC中的解決方案,兩者之間的交互將非常輕鬆。

如果我設置在TableTools.js全部或到我的資源的相對路徑它的工作原理

TableTools.DEFAULTS = { 
"sSwfPath": "http://localhost:51203/Content/copy_csv_xls_pdf.swf", 
"sRowSelect":  "none", 
"sSelectedClass": null, 
"fnPreRowSelect": null, 
"fnRowSelected": null, 
"fnRowDeselected": null, 
"aButtons":  [ "copy", "csv", "xls", "pdf", "print" ], 
"oTags": { 
    "container": "div", 
    "button": "a", // We really want to use buttons here, but Firefox and IE ignore the 
        // click on the Flash element in the button (but not mouse[in|out]). 
    "liner": "span", 
    "collection": { 
     "container": "div", 
     "button": "a", 
     "liner": "span" 
    } 
} 

}所需的SWF路徑;

如果我嘗試在組件初始化中試用它,它似乎不會在初始化中分配它。

$('.ReservationTable').dataTable({ 
    "sDom": 'T<"clear">lfrtip', 
    "oTableTools": { 
     "aButtons": ["copy"], 
     "sSwfPath": "http://localhost:51203/Content/copy_csv_xls_pdf.swf" 
    } 
}); 

任何提示?

回答

2

該錯誤是由於在同一頁面上具有多個具有相同類的DataTable並試圖以這種方式初始化多個數據表的做法很好,但不適用於oTableTools。

更改爲每個表的獨立初始化將按id排序。

$('#ReservationTable').dataTable({ 
"sDom": 'T<"clear">lfrtip', 
"oTableTools": { 
    "aButtons": ["copy"], 
    "sSwfPath": "http://localhost:51203/Content/copy_csv_xls_pdf.swf" 
} 

});