Wijmo UI for the Web
cellFormatter Option

This function is called each time wijgrid needs to create cell content. This occurs when rows are being rendered or cell editing is about to finish. You can use it to customize cell content.

Syntax
Javascript (Usage) 
$(function () {
    
    // Get value
    var returnsValue; // Type:  Function
    returnsValue = $(".selector").c1field("option", "cellFormatter");
    
    // Set value
    var newValue; // Type:  Function
    $(".selector").c1field("option", "cellFormatter", newValue);
        
});
Javascript (Specification) 
var cellFormatter : Function;
Example
// Add an image which URL is obtained from the "Url" data field to the column cells.
$("#demo").wijgrid({
    data: [
        { ID: 0, Url: "/images/0.jpg" },
        { ID: 1, Url: "/images/1.jpg" }
    ],
    columns: [
        {},
        {
            cellFormatter: function (args) {
                if (args.row.type & wijmo.grid.rowType.data) {
                    args.$container
                        .empty()
                        .append($("<img />")
                            .attr("src", args.row.data.Url));
                    return true;
                }
            }
        }
    ]
});
Remarks
Important: cellFormatter should not alter content of header and filter row cells container.
Browser Compatibility
7
5
5

See Also

Reference

options type
c1field jQuery Widget

 

 


© 2013 All Rights Reserved.

Send comments on this topic.