Get row values of GtkTreeView in PHP

149 Views Asked by At

How can I retrieve the row data from a GtkTreeView in PHP?

My try:

// $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();

Thank you for helping!

greets leon22

PS: I have a table with 2 columns and n rows (added the rows with $this->guidata->append($row) )

1

There are 1 best solutions below

0
On BEST ANSWER

The iteration goes over GtkListStore not GtkTreeView! With this code you can retrieve the values from the list!

    $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                                  
    }   

function to be able to add key/value pairs to an array

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