2012-08-03 118 views
1

嗨,我使用的是數據,並使用異步XHR調用對錶進行了laoding。我願意做this,但由於我使用xhr調用表,我的fnCreateSelect函數說由於沒有表數據,所以參數未定義。有沒有辦法在fnInitComplete中調用fnDrawCAllback,反之亦然?在數據表中使用fnInitComplete函數中的fnDrawCallback

任何關於如何做到這一點的建議將不勝感激。

一些代碼:這是我的fnInitcomplete函數我也使用固定列,如果有幫助。

"fnInitComplete": function() { 
       $("thead th").each(function (i) { 
        this.innerHTML += "<div class='DataTables_sort_wrapper'><span class='css_right ui-icon ui-icon-carat-2-n-s'></span></div><br/>"+fnCreateSelect(fleetT.fnGetColumnData(i)); 
        $("thead select").each(function (i) { 
         this.visibleIndex = i; 
        }); 
        $('select', this).change(function() { 
        var visIndex = typeof this.visibleIndex == 'undefined' ? 1 : this.visibleIndex; 
        fleetT.fnFilter($(this).val(), visIndex); 
       }); 
      }); 
      new FixedColumns(fleetT, { 
     "iLeftColumns": 2, 
     "iLeftWidth": 220 
    }); 

回答

0

你正在嘗試做的效果很好,當所有數據已經​​在客戶端上,因爲它可以得到不同的值,以創建一個選擇。但是,如果您執行服務器端分頁,則客戶端只有一小部分數據集,因此無法獲得完整數據集的不同值,但僅適用於此時管理的10/25行。 我的建議很簡單,就是創建選擇服務器端(通過對數據庫進行正常的DISTINCT查詢),然後像正常一樣渲染它們。