2016-10-05 29 views
0

在我的應用程序中,我需要顯示第一個數據表列中的數據條目的索引,並且它必須在DnD後工作(所以我認爲應該動態刷新列)。但Webix數據表中可能如何呢?如何在datatacle中顯示實際物品的索引?

現在,我可以使用​​手動獲取索引,但此方法在列模板中不起作用。例如:

/* inside the config */ 
    drag:true, 
    columns:[  
    { id:"index", template:function(obj){ 
     console.log(obj.id); 
     // doesn't work: 
     // console.log(datatable.getIdByIndex(obj.id)); 
    } }, 
    { id:"id" },  
    { 
     id:"title", fillspace:true, sort:"string"  
    } 
    ], 
    ready:function(){ 
    this.eachRow( 
     function (row){ 
     console.log(this.getIndexById(row)) // works 
     } 
    ) 
    } 
}); 

/* somewhere else */ 
console.log(datatable.getIdByIndex(4)); 

Code sample

這可能嗎?謝謝。

回答

0

要獲得行(數據錄入)的指數,你必須定義索引模板:

template: function(obj){ 
    return $$("dt").getIndexById(obj.id); } 

其中「DT」是你的數據表的ID。當您執行任何DnD操作時,它會自動更改索引。此外,請檢查代碼段here

+0

哦,我的,這只是我犯了一個可怕的錯誤,因爲我嘗試了相反的方法(/ __-;)我想知道我是否應該刪除這個主題,但無論如何,謝謝! – drewney

相關問題