views:

596

answers:

2

How to display an image instead of a bool value in a cell in datatable? The datatable is associated with a datasource.

+2  A: 

You can put any HTML into your cells by using a custom formatter function. Your Column definition might look like this:

var myColumnSet = [
    {
        key: 'active_employee',
        label: 'Active',
        formatter: function(el, oRecord, oColumn, oData) {
            // el is the HTMLElement of the current cell
            // oRecord gives you access to other fields from the
            //    DataSource, e.g.: oRecord.getData('full_name')
            // oData is the value of the current field (active_employee)

            if (oData) {
                el.innerHTML = '<img src="/images/active.png">';
            } else {
                el.innerHTML = '<img src="/images/not-active.png">';
            }
        }
    },
    // other Columns....
];

Also see the Custom Cell Formatting example.

Nate
A: 

How to store them in DATATABLE using C# in WPF

Aizaz
Check out if there are relevant question already if not post it with more details as a new question.
srikanthv