문제

Ajax 테이블을 위해 모든 정보가 즉시 생성 될 때 누군가가 열에 nowrap = "nowrap"을 추가하는 방법의 예를 제시 할 수 있습니까?

$('#results').dataTable({
    "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
        $(nRow).attr('id', aData[0]);
        return nRow;
    },
    "bAutoWidth": false,
    "sPaginationType": "full_numbers",  
    "bProcessing": true,
    "sAjaxSource": 'ajax/purchasers.php',
    "aaSorting": [[1,'asc']],                   
    "aoColumns": [                              
        { "bVisible": false },                      
        null,                                   
        null,
        null,
        null,
        null,
        null,
        null
    ]
});

나는 이것이 긴 샷 일지 알고있다. 미리 감사드립니다.

도움이 되었습니까?

해결책 3

누구나 솔루션에 관심이 있으시면 FninitComplete를 사용하여 DataTables가 완료된 후 테이블 위로 반복 할 수 있습니다.

$('#results').dataTable({
    "fnInitComplete": function() {
        $('#results tbody tr').each(function(){
                $(this).find('td:eq(0)').attr('nowrap', 'nowrap');
        });
    },
    "sAjaxSource": 'ajax/purchasers.php'
});

다른 팁

대신 스타일링을 통해 이것을 달성하는 것이 좋습니다.

"aoColumns": [                              
    { "sClass": "my_class"},

스타일 시트에서

    .my_class {
   white-space:nowrap;
 }

클래스를 추가하고 CSS 항목을 만들기 위해 확실히 작동하지만 망치를 사용하여 나사에서 파운드를 두는 것 같습니다.

Datatables는 이미 쉽게 수행하는 방법을 제공합니다.

데이터 가능한 선언에서 추가 :

"fnRowCallback": function( nRow ) {
    if(nRow.cells[2]) nRow.cells[2].noWrap = true;  // column index starts with 0 and we check if cells[2] is null to be ultra safe
    return nRow;
},

도움이 되었기를 바랍니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top