This project is archived and is in readonly mode.

#168 ✓resolved
Daniele C.

New Feature for HtmlTable

Reported by Daniele C. | October 28th, 2009 @ 11:08 AM | in 1.2.4.3

hi all,
These days I'm very eploring the HtmlTable class and it's uses. That's because I've developed a project for our company, where, with some scripts, I do EXACTLY the same things of HtmlTable (with code larger 3 times :-( ). One thing I've seen is HtmlTable miss is a way to set properties in the TRs it creates.

So I've wrote this simple script that create a new push method for the HtmlTable.

HtmlTable = Class.refactor(HtmlTable, {
    push: function(rowData, target, tag){
        var row = rowData;
        if($type(rowData) == 'object')
            row = rowData.row;
            
        var rowProperties = rowData.properties || {};
            
        var ret =  this.previous(row, target, tag);
        ret.tr.set(rowProperties);          
        return ret;
    }
});

This allow to add at the tr tag some properties (e.g. class = "MyClass", id = "MyID", customProperty = "Custom").

I think this can be really usefull in the case you want to display some fields from the DB, but keep some other undisplayied (e.g. from a Person Table, display firstname, lastname, email, but give as ID of each row the PK of the table).

I've prepared an example with the cities name and Timezone displayed, that retrieve the ID and the Geo Latitude and Longitute after selecting the Row.

http://mooshell.net/LrQVS/2

(I've pasted so much Code because MooShell still have 1.2.4.1, you can see the code I've wrote at the bottom of the Javascript part)

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

The MooTools Extensions

People watching this ticket

Pages