From ca7fbf44ad6567e559ef2282eaedab9398d5840d Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 14 Dec 2012 13:14:03 +0530 Subject: [PATCH] make a grid column required --- public/js/legacy/widgets/form/grid.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/public/js/legacy/widgets/form/grid.js b/public/js/legacy/widgets/form/grid.js index 6bac4513d5..946bc9cc93 100644 --- a/public/js/legacy/widgets/form/grid.js +++ b/public/js/legacy/widgets/form/grid.js @@ -151,6 +151,16 @@ _f.Grid.prototype.set_column_disp = function(fieldname, show) { this.reset_table_width(); } +_f.Grid.prototype.toggle_reqd = function(fieldname, reqd) { + // IMPORTANT: this should be called in refresh event + var grid_field = this.get_field(fieldname); + grid_field.df.reqd = reqd ? true : false; + grid_field.refresh(); + + $(grid_field.grid.head_row).find('[data-grid-fieldname="' + grid_field.grid.doctype + + '-' + fieldname + '"]').css({ color: reqd ? "#D22" : "black" }); +} + _f.Grid.prototype.append_row = function(idx, docname) { if(!idx)idx = this.tab.rows.length; var row = this.tab.insertRow(idx);