calculated field in record grid

A place for users and developers of the Xataface to discuss and receive support.

calculated field in record grid

Postby samhans » Thu Mar 22, 2012 8:03 am

hai Steve and all,

i have a table of stock of cartridges and outgoing cartridges . i have generated a query using record grid to display a table where it will show total item in stock and how much consumed. it works fine. but i want a third column balance in which i could subtract the two column values .

i want to know how in record grid i can subtract two columns .

help will be appreciative.

thanks samhans
samhans
 
Posts: 96
Joined: Fri Feb 10, 2012 1:22 am

Re: calculated field in record grid

Postby shannah » Thu Mar 22, 2012 10:04 am

Can you post your code?
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: calculated field in record grid

Postby samhans » Sat Mar 24, 2012 8:07 pm

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 />";

if(!$result)
{
// Error handling
$body .= "MySQL Error ...";
}else
{
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
samhans
 
Posts: 96
Joined: Fri Feb 10, 2012 1:22 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 4 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved