_f.FormGrid = function(field) { this.field = field; this.doctype = field.df.options; if(!this.doctype) { show_alert('No Options for table ' + field.df.label); } this.col_break_width = cint(this.field.col_break_width); if(!this.col_break_width) this.col_break_width = 100; $y(field.parent,{marginTop:'8px'}); this.init(field.parent, field.df.width); this.setup(); } _f.FormGrid.prototype = new _f.Grid(); _f.FormGrid.prototype.setup = function() { this.make_columns(); } _f.FormGrid.prototype.make_tbar_link = function(parent, label, fn, icon) { var div = $a(parent,'div','',{cursor:'pointer'}); var t = make_table(div, 1, 2, '90%', ['20px',null]); var img = $a($td(t,0,0),'div','wn-icon ' + icon); $y($td(t,0,0),{textAlign:'right'}); var l = $a($td(t,0,1),'span','link_type',{color:'#333'}); l.style.fontSize = '11px'; l.innerHTML = label; div.onclick = fn; div.show = function() { $ds(this); } div.hide = function() { $dh(this); } $td(t,0,0).isactive = 1; $td(t,0,1).isactive = 1; l.isactive = 1; div.isactive = 1; img.isactive = 1; return div; } _f.FormGrid.prototype.make_buttons = function() { var me = this; this.tbar_btns = {}; this.tbar_btns['Del'] = this.make_tbar_link($td(this.tbar_tab,0,0),'Del', function() { me.delete_row(); }, 'ic-round_minus'); this.tbar_btns['Ins'] = this.make_tbar_link($td(this.tbar_tab,0,1),'Ins', function() { me.insert_row(); }, 'ic-round_plus'); this.tbar_btns['Up'] = this.make_tbar_link($td(this.tbar_tab,0,2),'Up', function() { me.move_row(true); }, 'ic-arrow_top'); this.tbar_btns['Dn'] = this.make_tbar_link($td(this.tbar_tab,0,3),'Dn', function() { me.move_row(false); }, 'ic-arrow_bottom'); for(var i in this.btns) this.btns[i].isactive = true; } _f.FormGrid.prototype.make_columns = function() { var gl = fields_list[this.field.df.options]; if(!gl) { alert('Table details not found "'+this.field.df.options+'"'); } gl.sort(function(a,b) { return a.idx - b.idx}); var p = this.field.perm; for(var i=0;i'; c.cur_label = label; break; } } } _f.FormGrid.prototype.refresh = function() { var docset = getchildren(this.doctype, this.field.frm.docname, this.field.df.fieldname, this.field.frm.doctype); var data = []; //alert(docset.length); for(var i=0; i 0) { var swap_row = this.tab.rows[r.rowIndex - 1]; } else if (!up) { var len = this.tab.rows.length; if(this.tab.rows[len-1].is_newrow) len = len - 1; if(r.rowIndex < (len-1)) var swap_row = this.tab.rows[r.rowIndex + 1]; } if(swap_row) { var cidx = _f.cur_grid_cell.cellIndex; this.cell_deselect(); // swap index var aidx = locals[this.doctype][r.docname].idx; locals[this.doctype][r.docname].idx = locals[this.doctype][swap_row.docname].idx; locals[this.doctype][swap_row.docname].idx = aidx; // swap rows var adocname = swap_row.docname; this.refresh_row(swap_row.rowIndex, r.docname); this.refresh_row(r.rowIndex, adocname); this.cell_select(this.tab.rows[swap_row.rowIndex].cells[cidx]); this.set_unsaved(); } }