public Table CreateAutoTable(string name, bool dynamic = false, string items = ",", bool primary = false) { var t = new Table() { Name = name, Description = "Automatic Table", Primary = primary, Dynamic = dynamic }; string[] cols = "".Split(','); var tf = new TableField(); int count = 0; foreach (string c in cols) { if (string.IsNullOrEmpty(c)) { tf = new TableField() { Name = $"{c}", DataType = typeof(string), ViewDataType = "text" } } ; else { tf = new TableField() { Name = $"Col{count}", DataType = typeof(string), ViewDataType = "text" } }; t.Fields.Add(tf.Name, tf); count++; } return(t); }
public ViewFieldGroup CreateViewFieldGroup(TableField tf) { var vfg = new ViewFieldGroup(); var vf = tf as ViewField; if (string.IsNullOrEmpty(vf.Group)) { if (".text.number.date.time.url.email.file.search".IndexOf(tf.ViewDataType) > 0) { vf.HTMLControl = "input"; vf.HTML5Type = tf.ViewDataType; vf.PlaceHolder = vf.Name; vf.Caption = ""; vfg.Fields.Add(vf); } else if (!string.IsNullOrEmpty(vf.RelatedTable)) { //combo vf.HTMLControl = "select"; vf.Group = vf.RelatedTable; if (Tables[vf.RelatedTable].Dynamic) { ViewField vfText = new ViewField($"{vf.Name}_input"); vfText.PlaceHolder = vf.Name; vfText.Group = vf.RelatedTable; ViewField vfButton = new ViewField($"{vf.Name}_button"); vfButton.HTMLControl = "button"; vfButton.Caption = "+"; vfButton.Group = vf.RelatedTable; vf.Caption = ""; vfText.Caption = vf.Name; vfg.Fields.Add(vf); vfg.Fields.Add(vfText); vfg.Fields.Add(vfButton); } else { vfg.Fields.Add(vf); } } } else { vfg.Name = vf.Group; //todo project group fields and build FieldGroup } return(vfg); }
public ViewFieldGroup(TableField tf) { Fields = new List <ViewField>(); }
public void AddField(TableField f) { Fields.Add(f.Name, f); }