[ANN] CKHTMLTable 0.1

Hi,

this is my first announcement here. I hope I'm not too verbose, but I want to be sure you see the usefulness of this :slight_smile:

In my development of web interfaces, I often have to display rows coming from a database in a HTML table, with some fields being hyperlinks (to, for example, a details page of the row), with navigation links when the list returned is to long to be displayed on one page, with possibility to sort by the values in a certain column.

I developed such a component for cgikit and called it CKHTMLTable.
You can download it at http://www.raphinou.com/CKHTMLTable-latest.tgz and find a web page on the web with some explanations:
http://www.raphinou.com/wiki/wiki/show/CKHTMLTable+Details
A little example is also available for download at http://www.raphinou.com/CKHTMLTableExample.tgz

If you don't know cgikit, I can only encourage you to take a look at it (http://www.spice-of-life.net/cgikit/index_en.html). It works with three files: html "template", binding file, and ruby code file and has inspiration in WebObjects.

The component makes it very easy to display data in a HTML table, with possibly navigation links and sorting.

For example, to display an array in a table, here what is needed:

···

##############
#html template
<cgikit name="ExampleTable1"/>

############
#ckd binding
ExampleTable1 : CKHTMLTable{
     item_list = list;
     fields = fields;
}

##########
#ruby file
@list = [ ["r1f1","r1f2","r1f3"],
           ["r2f1","r2f2","r2f3"],
           ["r3f1","r3f2","r3f3"],
           ["r4f1","r4f2","r4f3"],
           ["r5f1","r5f2","r5f3"]
  ]
@fields = [ "field 1",
                     "field 2",
                     "field 3"
           ]

To hide a column, just add this

############
#ckd binding, in the ExampleTable1
linked_fields = linked_fields2;

##########
#ruby file
@linked_fields2 = LinkedFields.new
@linked_fields2.add_hidden "field 1"

To have "field 2" being a link to the Details element, do this in your ruby file:

         link = LinkSpec.new "field 2"
         link.page="Details"
         link.set_query("detail_value","field_value(\"field 1\")")
         link.add_query_eval("detail_value")
         @linked_fields2.add_link link

If you want to know more, look at the working example available for downlod.

Hoping this will be useful to some of you.

Raph

Bauduin Raphael wrote:

Hi,

this is my first announcement here. I hope I'm not too verbose, but I want to be sure you see the usefulness of this :slight_smile:

No, not too verbose. And, in general, I prefer when people write a nice, detailed announcement, so that they need only post *one* message, rather than writing too little, where a dozen people then have to ask questions and provoke a dozen responses.

Less work all around, I think.

And nice work on CKHTMLTable.

James