User Tools

Site Tools


jqgrid_hover

I wanted to have a column of data gathered from a mysql timestamp type but didn't want to display the time in the jqgrid column, just the date. Then I wanted to allow a user to see the entire entry, date and time, when hovering over a cell. Here's one way to do it. First create your column including the formatter attribute:

  colModel: [
                    {
                        name: 'memberid',
                        index: 'memberid',
                        hidden:true,
                    },
                    {
                        name: 'lastmod',
                        index: 'lastmod',
                        width: 65,
                        hidden:true,
                        formatter:stripTime,
                        sorttype: "text"
                    },

Then use something like this to format:

function stripTime(cellValue,options,rowObject) {
    console.dir(rowObject);
    var x= rowObject.lastmod.substring(0,10);
    return '<span title="' + rowObject.lastmod+'">'+ x +'</span>';
    return rowObject.lastmod;
    return rowObject.lastmod.substring(0,10);
}

Show demo

jqgrid_hover.txt · Last modified: 2015/06/11 18:30 by admin