webismymind / editablegrid

EditableGrid is an open source Javascript library aimed at turning HTML tables into advanced editable components. It focuses on simplicity: only a few lines of code are required to get your first table up and running.
http://www.editablegrid.net
Other
796 stars 271 forks source link

Enter hh:mm:ss #206

Closed TrevorStokes closed 3 years ago

TrevorStokes commented 3 years ago

I would like to enter a time (not time of day, an elapsed time). You home page says... Possibility to plug your own cell renderers, editors and validators ... but I couldn't figure out where to do that.

TrevorStokes commented 3 years ago

I think I have solution. Treat the field as a string. Use cellValidator like this one

grid.addCellValidator("time", new CellValidator({ 
            isValid: function(value) { return value == "" || 
            value.search(/^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$/)==0; }
        }));

And probably a renderer.