/// class PD.Web.UI.Controls.GridCheckboxColumn
/// using PD.Web.UI.Controls.GridColumn

PD.Web.UI.Controls.GridCheckboxColumn =
PD.Web.UI.Controls.GridColumn.extend({

    //===================================
    // CONSTRUCTOR
    //===================================

    init: function (options) {

        this._super($.extend({
            width: 26,
            title: "&nbsp;",
            readOnly: false,
            template: $.proxy(this.template, this),
            transform: function (data) {
                return data[this.properties("field")];
            },
            attributes: {
                style: "padding:3px 3px 3px 3px;text-overflow:clip;"
            },
            headerAttributes: {
                "class": "-pd-noresize"
            }
        }, options));

    },

    //===================================
    // PUBLIC METHODS
    //===================================

    template: function (data) {

        var value = _.bind(this.properties("transform"), this)(data);
        var readOnly = this.properties("readOnly");

        var result = [
                "<div style='width:100%;height:16px;box-sizing:border-box;position:relative;padding:2px 3px 0 3px;text-align:center;'>",
                    "<input type='checkbox' style='margin:0;' " + (value ? "checked" : "") + " " + (readOnly ? "disabled" : "") + " />",
                "</div>"
            ];

        return result.join("");

    }

});