Page 1 of 1

record grid

PostPosted: Mon Mar 26, 2012 9:34 am
by samhans
hai Steve and all,
this is my record grid action code:

class actions_testTableAction {

// Will be called from Xataface, if this action is called
function handle(&$params){
$this->app =& Dataface_Application::getInstance(); // reference to Dataface_Application object

// Custom query
$result = mysql_query("select id, in_stock, outstock from( (select id, sum(qty) from inciming )as in_stock) left join (select id, sum(out_qty) from outgoing_catridge) as outstock) group by printr_model ", $this->app->db());
$body = "<br /><br />";

// Error handling
$body .= "MySQL Error ...";
while($row = mysql_fetch_assoc($result)) // Fetch all rows
// Maybe do something with the single rows
$data[] = $row; // Add singe row to the data
mysql_free_result($result); // Frees the result after finnished using it

$grid = new Dataface_RecordGrid($data); // Create new RecordGrid with the data

$body .= $grid->toHTML(); // Get the HTML of the RecordGrid

// Shows the content (RecordGrid or error message) in the Main Template
df_display(array('body' => $body), 'Dataface_Main_Template.html');

steve this is the code in action , it is working fine but what i want is a third column balance where i could minus the in stock and outstock rows to get the value.
i have done it when i use to echo my owntable. but i dont know how could i insert in a record grid object.

thanks for help