2013-10-31 30 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" 
} 

});