CodeIgniter Forums
Tables with no headings - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Tables with no headings (/showthread.php?tid=37693)



Tables with no headings - El Forum - 01-17-2011

[eluser]Unknown[/eluser]
I'd like to be able to set up a table with no headings so that I can set my own, the table I'm currently working on has 3 header rows with colouring.

Now I've modified table.php to achieve this but I was wondering if there was a better way.

What I've done is to add a new method to allow the auto heading variable to be changed:

function set_auto_heading($set_value)
{
$this->auto_heading = $set_value;
}

then I've added a modification to the _set_from_object method to check the variable:

function _set_from_object($query)
{
if ( ! is_object($query))
{
return FALSE;
}

// First generate the headings from the table column names
if (count($this->heading) == 0 AND $this->auto_heading == TRUE)
{ ....


This achieves what I want at the expense of having to maintain this code change in every new release.

I'd request it as a new "feature" except that I can't post there and besides which one of you super-clever CI people might know a better way to do this.

TetleyK


Tables with no headings - El Forum - 01-17-2011

[eluser]InsiteFX[/eluser]
You do not need to maintain it!

If you read the CodeIgniter User Guide all you need to do
is extented the Table Class and make your changes!

InsiteFX


Tables with no headings - El Forum - 01-18-2011

[eluser]Unknown[/eluser]
Very helpful NOT!

Yes, I could extend the base class but then I end up with duplicated code and if you know *anything* about professional programming you'll also know that this is not a desired outcome. Ever heard of the term "refactoring"? I suggest you look it up.

That said, your reply doesn't answer the question which is "is there a better way to use CI to get a headerless table?". That is does someone out there is CI land have a way of using existing CI classes and routines to generate a table with no headers or, more precisely, one where the headers, data and format, are completedly defined by the developer.

Awaiting an informative reply...