Welcome Guest, Not a member yet? Register   Sign In
Best Practice...where to generate a table
#1

[eluser]blasto333[/eluser]
In a program I am writing, I have a module for adding, updating, deleting, and viewing customers. In my customer model, I created a function get_manage_table, that creates an html table and returns as a string.

The result of this function is then passed into a view from my controller and outputted. Is this the way to go?

Code:
function get_manage_table($customers)
{
    $this->table->set_template(get_sortable_table_template());
    $this->table->set_heading('<input type="checkbox" id="select_all" />',
    $this->lang->line('common_last_name'),
    $this->lang->line('common_first_name'),
    $this->lang->line('common_email'),
    $this->lang->line('common_phone_number'),
    ' ');
    
    foreach($customers as $customer)
    {
        $checkbox = "<input type='checkbox' id='customer_$customer->id' value='$customer->id'/>";
        $this->table->add_row($checkbox,$customer->first_name,$customer->last_name,
        $customer->email,$customer->phone_number,
        anchor("customer/edit/$customer->id", $this->lang->line('common_edit'),array('class'=>'thickbox')));
    }
    
    $output = $this->table->generate();
    $this->table->clear();
    
    return $output;
}


Messages In This Thread
Best Practice...where to generate a table - by El Forum - 10-13-2008, 04:47 PM
Best Practice...where to generate a table - by El Forum - 10-13-2008, 06:28 PM
Best Practice...where to generate a table - by El Forum - 10-13-2008, 06:46 PM
Best Practice...where to generate a table - by El Forum - 10-13-2008, 07:29 PM
Best Practice...where to generate a table - by El Forum - 10-13-2008, 07:33 PM
Best Practice...where to generate a table - by El Forum - 10-13-2008, 07:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB