Welcome Guest, Not a member yet? Register   Sign In
Table Class issues
#1

[eluser]shiggins[/eluser]
Does anyone understand why when using the table class, style attributes only apply to the first row?

Code:
$tmpl = array ( 'table_open'  => '<table border="0" width="100%" cellpadding="2" cellspacing="0" align="left">',  
                'heading_row_start'   => '<tr>',
                'heading_row_end'     => '</tr>',
                'heading_cell_start'  => '<th class="tblhead">',
                'heading_cell_end'    => '</th>',
                'row_start'              => '<tr>',
                'row_end'              => '</tr>',
                'cell_start'          => '<td class="tblcell">',
                'cell_end'              => '</td>'                            
               );

When looping through a set of records the style class 'tblcell' is only applied to the first set of records.

Thanks in advance!
#2

[eluser]axle_foley00[/eluser]
shiggins:

I'm not quite sure why it's only happening to the first row for you. I did however notice that it seems when you specify a style on a table cell/row, the table that is generated alternates the style for every other row by default. So in other words you will end up with something like this being generated:

Code:
<table border="0" width="100%" cellpadding="2" cellspacing="0" align="left">
<tr>
    <th class="tblhead">Name</th>
    <th class="tblhead">Color</th>
    <th class="tblhead">Size</th>
</tr>
<tr>
    <td class="tblcell">Fred</td>
    <td class="tblcell">Blue</td>
    <td class="tblcell">Small</td></tr>
<tr>
    <td>Mary</td>
    <td>Red</td>
    <td>Large</td>
</tr>
<tr>
    <td class="tblcell">John</td>
    <td class="tblcell">Green</td>
    <td class="tblcell">Medium</td>
</tr>
</table>

Is this what is happening to you? Could you show us an example of your controller code?

Edit:

I'm thinking that you may want to specifiy some additional template configurations, so that the alternate rows have the same styles as the others. So your template config would look like this instead:

Code:
$tmpl = array (
          'table_open'  => '<table border="0" width="100%" cellpadding="2" cellspacing="0" align="left">',  
          'heading_row_start'   => '<tr>',
          'heading_row_end'     => '</tr>',
          'heading_cell_start'  => '<th class="tblhead">',
          'heading_cell_end'    => '</th>',
          'row_start'              => '<tr>',
          'row_end'              => '</tr>',
          'cell_start'          => '<td class="tblcell">',
          'cell_end'              => '</td>',
          'row_alt_start'       => '<tr>',
          'row_alt_end'         => '</tr>',
          'cell_alt_start'      => '<td class="tblcell">',
          'cell_alt_end'        => '</td>',
        );

Notice the last 4 configuration items are similar to the 4 items just above it. I don't think it should be necessary to use those last 4 items unless you actually want the rows to alternate. But it might help in your case.

Does anyone else notice that it automatically alternates the rows?

UPDATE: Actually I just looked through the HTML Table Class Library and it has a default template config. So just in case you don't set a particular template config item, it will use the one from the default template. Perhaps that could be why you are having this problem.
#3

[eluser]shiggins[/eluser]
I know that using row_alt_start is designed to allow alternating style values such as row colors, but I'm not looking for that. All I need is for each row to use the same class..

Code:
//set table headings                    
        $this->table->set_heading("",MODEL_NAME,TYPE,MANUFACTURER,LEVEL,CERTIFIED,MAILING_LIST,ACTION,"");
        
        //set human values for expertise and certified
        $expertiseLvl = array("1"=>LEVEL_LOW,"2"=>LEVEL_AVERAGE,"3"=>LEVEL_GOOD,"4"=>LEVEL_EXPERT);
        $certified = array("1"=>CERTIFIED_YES,"2"=>CERTIFIED_NO);
        
        //loop through each record
        foreach($vals as $ex):
        
        //add a row for each record
        $this->table->add_row(
        
        form_open('members/experts_class/doupdate/' .$ex["id"]), //opens form with path and record id for updating
        
        anchor('equipment/equipment_class/' .$ex["equipment_id"]. '',$ex["model"]), //link the model to the model info
        
        "","",
        
        form_dropdown('expertise', $expertiseLvl, $ex["expertise"]), //create drop down list for expertise
        
        form_dropdown('certified', $certified, $ex["certified"]), //create drop down list for certified
        
        $ex["mailing_list"],form_submit('mysubmit', UPDATE_DATA), //mailing list and submit button
        
        form_close() //close form
        
        );
        
        endforeach; //end loop
        
        $this->table->set_template($tmpl); //set template
        
        echo $this->table->generate(); //generate the table

Above code is used to create the table and loop through the records.
#4

[eluser]axle_foley00[/eluser]
Hmm...I tried my best to replicate what you had done, but I'm not having any problems with the cells as you described.

Any particular reason why the TYPE and MANUFACTURER columns are blank or were those taken out just for the sample in your post?

Could you also post a sample of the HTML table that was generated?




Theme © iAndrew 2016 - Forum software by © MyBB