Welcome Guest, Not a member yet? Register   Sign In
Creating Uniquie TR id's with the HTML table class
#1

[eluser]adamBouchard[/eluser]
Hello,

I'm trying to figure out how to add uniquie id's to TR's using the HTML table class.

In the following two functions, I am creating a table based on $data from a sql result. I want to be able to pass in the id for each row into the "TR" tag, so the user can click on the row to drill down.

Has any one ran into this situation yet?

Thanks,


here is my code:

public function get_results_table($data,$num,$template = 'filter')
{
//get the array keys and assign as the table headings
$th = array_keys($data[0]);

//set the caption
$this->ci->table->set_caption($num." ".$this->ci->application->action);

//set the headings
$this->ci->table->set_heading($th);

//set the template
$template_method = "_".$template."_template";
$tmpl = $this->$template_method();
$this->ci->table->set_template($tmpl);

//create non-breaking space if any value is empty
$this->ci->table->set_empty(" ");

//return the table
return $this->ci->table->generate($data);
}

private function _filter_template()
{
//TODO: HOW DO I PASS THE UNIQUE row ID into the TR????

$tmpl = array (
'table_open' => '<table>',
'row_start' => '<tr id="">',
'row_alt_start' => '<tr id="">',

);
return $tmpl;
}
#2

[eluser]elvix[/eluser]
i just posted my extension to the table class in the wiki. the instructions are pretty straightforward, and you can read the code for more info -- it's pretty self-explanatory.

http://codeigniter.com/wiki/MY_Table/

you can set widths on the first row, classes on each row of table cells, and row IDs along with your table data.

nothing fancy, but it gives you good control over displaying your data.
#3

[eluser]adamBouchard[/eluser]
Great thanks Smile




Theme © iAndrew 2016 - Forum software by © MyBB