1
我們在我們的應用程序中使用了數據表。 有人可以建議如何設置數據表內的列的寬度。無法修復數據表列的寬度
以下是基本配置:
WATable = $('#dtAssignment').dataTable({
"sScrollY": "150px",
"bAutoWidth": false,
"bPaginate": true,
"sPaginationType": "two_button",
"bLengthChange": true,
"iDisplayLength": DefaultRecordsPerPage,
"aLengthMenu": [[100, 250, 500], [100, 250, 500]],
"sDom": 'Trti<"row"<"two columns" l><"seven-by-five columns"<"#dvGoto">><"offset-by-seven" p>>',
"aoColumns": dtAssignmentData.template,
"aoColumnDefs": dtAssignmentData.columnDefs,
"fnDrawCallback": function(oSettings) {
我們正在aoColumns從ASP.NET MVC應用程序& aoColumnDefs數據。以下是來自服務器的示例JSON數據。
{"columnDefs":[{"sTitle":"Description","aTargets":"[0]","sWidth":"220px","sName":null,"sType":null},{"sTitle":"User ID","aTargets":"[1]","sWidth":"50px","sName":null,"sType":null},{"sTitle":"Date Added","aTargets":"[2]","sWidth":"80px","sName":null,"sType":null}],"template":[{"mDataProp":"Description","fnRender":null,"sClass":null,"mRender":null,"sWidth":null},{"mDataProp":"CreatedBy","fnRender":null,"sClass":null,"mRender":null,"sWidth":null},{"mDataProp":"CreationDate","fnRender":null,"sClass":null,"mRender":null,"sWidth":null}],"aaData":[{ ... BLAH..BLAH..BLAH
即使在設置「bAutoWidth」:false併爲每列設置sWidth之後,Datatable也會自動調整列的大小。