2017-06-06 57 views
1

我用數據表插件來顯示數據,但我改變表的數據用PHP和AJAX:排序表數據表的jquery的

$aColumns = array(
    'entity_id', 
    'entity_immatriculation', 
    'entity_designation', 
    'categorieentity_label', 
    'emplacemententity_label', 
    'familleentity_label', 
    'entity_date_destruction', 
    'entity_prix', 
    'id_entity_etat' 
); 

Model::factory('entity')->_ajax_entity($aColumns,$this->_controller); 

模塊:

foreach($rResult as $aRow) 
{ 
    $row = array(); 
    for ($i = 0; $i < count($aColumns); $i++) 
    { 
    if ($i == 6) 
    { 
     $row[] = $compteur; 
    } 
    }  
} 

的顯示是好的,但這種表格總是以舊值entity_date_destruction請幫忙。

回答

0

您可以使用下面的語法更改默認排序。

var table = $('#example').DataTable(); 

var data = table 
.column(0) 
.data() 
.sort(); 

它將排序w.r.t第一(0)列。