Added support for the password cell.

This commit is contained in:
Harshal Dhumal
2016-06-03 16:13:42 +05:30
committed by Ashesh Vashi
parent 6dbfb7db7e
commit 5eef63c068
2 changed files with 62 additions and 0 deletions

View File

@@ -845,6 +845,45 @@
}
});
/**
Formatter for PasswordCell.
@class Backgrid.PasswordFormatter
@extends Backgrid.CellFormatter
@constructor
*/
var PasswordFormatter = Backgrid.PasswordFormatter = function () {};
PasswordFormatter.prototype = new Backgrid.CellFormatter();
_.extend(PasswordFormatter.prototype, {
fromRaw: function (rawValue, model) {
if (_.isUndefined(rawValue) || _.isNull(rawValue)) return '';
var pass = '';
for(var i = 0; i < rawValue.length; i++) {
pass += '*';
}
return pass;
}
});
var PasswordCell = Backgrid.Extension.PasswordCell = Backgrid.StringCell.extend({
formatter: PasswordFormatter,
editor: Backgrid.InputCellEditor.extend({
attributes: {
type: "password"
},
render: function () {
var model = this.model;
this.$el.val(model.get(this.column.get("name")));
return this;
}
})
});
return Backgrid;
}));