PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Re:How to save the Prices value array after edited? (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:How to save the Prices value array after edited?


#3711
tomkuanq0705 (User)
Fresh Boarder
Posts: 13
graphgraph
User Offline Click here to see the profile of this user
How to save the Prices value array after edited? 2 Months ago Karma: 0  
hi kksou,
thank you for the sample code 139.^^ http://www.kksou.com/php-gtk2/articles/edit-items-in-GtkTreeView---using-built-in-treeview-edit---Part-2.php
now I want to save the value of the Prices after edited.
Code:
function on_edit_done($cell,$path,$new_text,$view,$col)
{
$model=$view->get_model();
$iter=$model->get_iter_from_string($path);
$model->set($iter,$col,$new_text);
}
function on_process_button($button)
{
global $data;
array2string($data,$output,$parent);

$f1=fopen("test.txt","w+");
fwrite($f1,$output);
fclose($f1);
echo "hihi\n";
}
function array2string($data,$output,$parentkey)
{
global $data;
foreach($myarray as $key=>$value)
{
if(is_array($value))
{
$parentkey.=$key.",";
array2string($value,$output,$parentkey);
$parentkey="";
}
else
{
$output.=$parentkey.$key.",".$value;
}
}
}
I creat button. if push the button,save array to file "test.txt". But I got 1 error mesage. "Invalid argument supplied for foreach() in..." please help me. Thank You very much. Best Regards, Tom Kuanq.
 
  The administrator has disabled public write access.

#3721
kksou (Admin)
Admin
Posts: 1240
graph
User Online Now Click here to see the profile of this user
Re:How to save the Prices value array after edited? 1 Month, 4 Weeks ago Karma: 20  
Hi,

Sorry for the late reply.

1) The $data is used only for populating the table with some sample data when it first started.

2) Once the value for each cell is being loaded, the values for each cell reside in the GtkListStore $model

3) Any changes when you edit the cell are also updated back into the $model

4) To save the value after editing, you need to retrieve the value from the $model.

You may want to refer to the following sample code:
Sample Code 196: How to iterate through a GtkListStore - Part 1?

It will show you how to retrieve the values from the GtkListStore.

Regards,
/kksou
 
  The administrator has disabled public write access.



Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2009. kksou.com. All Rights Reserved