2012-01-25 37 views
0

如何從PHP中的GtkTreeView中檢索行數據?獲取GtkTreeView在PHP中的行值

我嘗試:

// $this->guidata = new GtkListStore(); 
// $this->view = new GtkTreeView($this->guidata); 

$dutarray = array(); 

$selection = $this->view->get_selection(); 
$selection->select_all(); 

$dutArray = $selection->get_selected_rows(); 

謝謝你的幫助!

招呼leon22

PS:我有一個表2列和n行(加有$行這個 - > guidata->追加($行))

+0

沒有人?我如何從單元格中檢索文本數據? – leon22

回答

0

迭代越過GtkListStore不GtkTreeView!有了這個代碼,你可以從列表中檢索值!

$this->dutArray = array();  
    $iter = $this->guidata->get_iter_first(); 

    //$iterIndex = 1; 
    while (null != $iter) 
    { 
     $key = $this->guidata->get_value($iter, 0); 
     $value = $this->guidata->get_value($iter, 1); 

     $this->dutArray = $this->array_push_assoc($this->dutArray, $key, $value); 

     $iter = $this->guidata->iter_next($iter); // incement iterator         
    } 

功能以能夠鍵/值對添加到一個數組

public function array_push_assoc($array, $key, $value) 
    { 
     $array[$key] = $value; 
     return $array; 
    }