Welcome Guest, Not a member yet? Register   Sign In
How to add <tr> attribute id $this->table->add_row();
#1

[eluser]dimasVS[/eluser]
Hi all,
I need your help, how to add attribute(s) in table row <tr> ?

for example I want to create table like the example below :

<table>
<tr id="test"><td>Testing</td></tr>
</table>

how to create id="test" in $this->table->add_row() ?

Thank you very much...



Best Regards,

Dimas
#2

[eluser]Stockhausen[/eluser]
Hi,

i think it's impossible !

Read this information in the user guide http://ellislab.com/codeigniter/user-gui...table.html and look Changing the Look of Your Table zone

So generally id for CSS may be jus one time in a page. Préfer to use class for CSS.
#3

[eluser]dimasVS[/eluser]
[quote author="Stockhausen" date="1275387110"]Hi,

i think it's impossible !

Read this information in the user guide http://ellislab.com/codeigniter/user-gui...table.html and look Changing the Look of Your Table zone

So generally id for CSS may be jus one time in a page. Préfer to use class for CSS.[/quote]

Therefore I try to ask question in here, maybe any suggest to solve it.
I've been try to read the user guide and don't have any idea.

Do I create <tr> manually ?
#4

[eluser]Stockhausen[/eluser]
Please read this zone and put your

<tr id="what_you_want">

Changing the Look of Your Table

The Table Class permits you to set a table template with which you can specify the design of your layout. Here is the template prototype:
Code:
$tmpl = array (
                    'table_open'          => '<table border="0" cellpadding="4" cellspacing="0">',

                    'heading_row_start'   => '<tr>',
                    'heading_row_end'     => '</tr>',
                    'heading_cell_start'  => '<th>',
                    'heading_cell_end'    => '</th>',

                    'row_start'           => '<tr class="what_you_want">',
                    'row_end'             => '</tr>',
                    'cell_start'          => '<td>',
                    'cell_end'            => '</td>',

                    'row_alt_start'       => '<tr>',
                    'row_alt_end'         => '</tr>',
                    'cell_alt_start'      => '<td>',
                    'cell_alt_end'        => '</td>',

                    'table_close'         => '</table>'
              );

$this->table->set_template($tmpl);

Quote:Note: You'll notice there are two sets of "row" blocks in the template. These permit you to create alternating row colors or design elements that alternate with each iteration of the row data.


You are NOT required to submit a complete template. If you only need to change parts of the layout you can simply submit those elements. In this example, only the table opening tag is being changed:

Code:
$tmpl = array ( 'table_open'  => '<table border="1" cellpadding="2" cellspacing="1" class="mytable">' );
$this->table->set_template($tmpl);
#5

[eluser]dimasVS[/eluser]
[quote author="Stockhausen" date="1275391289"]Please read this zone and put your

<tr id="what_you_want">

Changing the Look of Your Table

The Table Class permits you to set a table template with which you can specify the design of your layout. Here is the template prototype:
Code:
$tmpl = array (
                    'table_open'          => '<table border="0" cellpadding="4" cellspacing="0">',

                    'heading_row_start'   => '<tr>',
                    'heading_row_end'     => '</tr>',
                    'heading_cell_start'  => '<th>',
                    'heading_cell_end'    => '</th>',

                    'row_start'           => '<tr class="what_you_want">',
                    'row_end'             => '</tr>',
                    'cell_start'          => '<td>',
                    'cell_end'            => '</td>',

                    'row_alt_start'       => '<tr>',
                    'row_alt_end'         => '</tr>',
                    'cell_alt_start'      => '<td>',
                    'cell_alt_end'        => '</td>',

                    'table_close'         => '</table>'
              );

$this->table->set_template($tmpl);

Quote:Note: You'll notice there are two sets of "row" blocks in the template. These permit you to create alternating row colors or design elements that alternate with each iteration of the row data.


You are NOT required to submit a complete template. If you only need to change parts of the layout you can simply submit those elements. In this example, only the table opening tag is being changed:

Code:
$tmpl = array ( 'table_open'  => '<table border="1" cellpadding="2" cellspacing="1" class="mytable">' );
$this->table->set_template($tmpl);
[/quote]



hmm, I think it just work on first row.
How to create it in every row ?
and the id/class dinamically change.

on the code below, I want to create id/class in ever row that printed in foreach.
example : $tmpl = array ( 'row_start' => "<tr id=\"$row->transaksi_jurnal_kasbank_id\">" );

it doesn't work, only printed on first row

Code:
&lt;?php
        echo form_open('kasBank/transaksiJurnalKasBank/hapus');
        echo "<a ><img ></a> &lt;input type=\"image\" src=\"" . base_url() . "/images/delete.jpg\" title=\"Hapus\"&gt;";
        $data = array('jurnal_kasbank_id' => $jurnal_kasbank_id);
        $this->db->select('*');
        $this->db->order_by('jurnal_kasbank_id', 'desc');
        $q = $this->db->get_where('csbk_transaksi_jurnal_kasbank', $data);
        $no = 1;
        
        $tbl = array ( 'table_open'  => '<table border="1" cellpadding="2" cellspacing="1" class="tableData" width="100%">');
        $this->table->set_template($tbl);
        
        $this->table->set_heading('No', 'Kode Alur Kas', 'Kode Perkiraan', 'Kode Segment 1', 'Kode Segment 2', 'Kode Segment 3', 'Kode Segment 4', 'Kode Segment 5', 'Jumlah', 'Edit', 'Hapus');
        if ($q->num_rows > 0){
            foreach($q->result() as $row){
                $this->table->add_row($no, $row->kode_alur_kas, $row->kode_perkiraan, $row->kode_segment_1, $row->kode_segment_2, $row->kode_segment_3, $row->kode_segment_4, $row->kode_segment_5, $row->jumlah, "<a >transaksi_jurnal_kasbank_id\" onclick=\"return editx()\"><img ></a>", "&lt;input type=\"checkbox\" name=\"hapus[]\" value=\"$row-&gt;transaksi_jurnal_kasbank_id\">");
                $no++;
            }
        }
        $this->table->set_template($tbl);
        echo $this->table->generate();
        echo "&lt;/form&gt;";
        echo validation_errors();
    ?&gt;
#6

[eluser]Stockhausen[/eluser]
row_alt_start maybe ?
#7

[eluser]dimasVS[/eluser]
[quote author="Stockhausen" date="1275393645"]row_alt_start maybe ?[/quote]

it also doesn't work..
Sad
#8

[eluser]bhogg[/eluser]
You could just build the table in a view using standard PHP/HTML and avoid this mess Smile

PHP itself makes for a nice templating language, for example:

Code:
&lt;?php if ($something === true): ?&gt;
<table>
&lt;?php foreach ($arrayval as $key => $val): ?&gt;
<tr>
   <td>&lt;?php echo $key; ?&gt;</td>
   <td>&lt;?php echo $val; ?&gt;</td>
</tr>
&lt;?php endforeach; ?&gt;
<table>
&lt;?php endif; ?&gt;

I found using the CI table functions hard for others to read/maintain/debug and with issues such as this one.
#9

[eluser]bhogg[/eluser]
Also, in your code, it looks like one of the problems is:

Code:
<a >transaksi_jurnal_kasbank_id\" onclick=\"return editx()\">

Should that > not be \"? Maybe either try standard HTML in a view, or format so the lines aren't so long and it's a bit easier to see/debug (ie. one line per element when building the table row)
#10

[eluser]dimasVS[/eluser]
[quote author="bhogg" date="1275396408"]You could just build the table in a view using standard PHP/HTML and avoid this mess Smile

PHP itself makes for a nice templating language, for example:

Code:
&lt;?php if ($something === true): ?&gt;
<table>
&lt;?php foreach ($arrayval as $key => $val): ?&gt;
<tr>
   <td>&lt;?php echo $key; ?&gt;</td>
   <td>&lt;?php echo $val; ?&gt;</td>
</tr>
&lt;?php endforeach; ?&gt;
<table>
&lt;?php endif; ?&gt;

I found using the CI table functions hard for others to read/maintain/debug and with issues such as this one.[/quote]

It just the last choice,




Theme © iAndrew 2016 - Forum software by © MyBB