2012-01-25 2 views
0

Как получить данные о строках из GtkTreeView в PHP?Получить значения строк для 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(); 

Благодарим Вас за помощь!

Greets leon22

PS: У меня есть таблица с 2 столбцов и п строк (добавляются строки с $ этом-> guidata-> Append ($ строка))

+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; 
    } 
Смежные вопросы