public static ClassicDetailTemplate FromColumnList(IEnumerable <column> columns) { var res = new ClassicDetailTemplate(); foreach (var col in columns) { res.AddColumn(col.header, col.content, col.style); } return(res); }
private void generate() { var jsonGen = new JSchemaGenerator { DefaultRequired = Newtonsoft.Json.Required.Default }; var schema = jsonGen.Generate(typeof(TData)); var types = GetPropertyNameTypeFromSchema(schema); if (types.Count(kv => kv.Key.ToLower() == "id") == 0) { throw new ArgumentNullException("Class Type", "Class must containt property 'Id' or 'id'"); } KeyValuePair <string, Type> idType = types.Where(kv => kv.Key.ToLower() == "id").FirstOrDefault(); search.AddColumn("Detail", "<a href=\"{{ fn_DatasetItemUrl item." + idType.Key + " }}\">Detail</a>"); int searchAdded = 0; foreach (var col in types) { if (col.Key.ToLower() != "id") { searchAdded++; if (searchAdded < 6) { if (col.Value == typeof(Nullable <DateTime>) || col.Value == typeof(DateTime)) { search.AddColumn(col.Key, "{{ fn_FormatDate item." + col.Key + " }}"); } else if (col.Value == typeof(Nullable <Date>) || col.Value == typeof(Date)) { search.AddColumn(col.Key, "{{ fn_FormatDate item." + col.Key + " }}"); } else if (col.Value == typeof(string)) { search.AddColumn(col.Key, "{{ item." + col.Key + " }}"); } else if (col.Value == typeof(Nullable <decimal>) || col.Value == typeof(decimal)) { search.AddColumn(col.Key, "{{ fn_FormatNumber item." + col.Key + " }}"); } else if (col.Value == typeof(Nullable <long>) || col.Value == typeof(long)) { search.AddColumn(col.Key, "{{ fn_FormatNumber item." + col.Key + " }}"); } else if (col.Value == typeof(Nullable <bool>) || col.Value == typeof(bool)) { search.AddColumn(col.Key, "{{ item." + col.Key + " }}"); } } if (col.Value == typeof(Nullable <DateTime>) || col.Value == typeof(DateTime)) { detail.AddColumn(col.Key, "{{ fn_FormatDate item." + col.Key + " }}"); } else if (col.Value == typeof(Nullable <Date>) || col.Value == typeof(Date)) { detail.AddColumn(col.Key, "{{ fn_FormatDate item." + col.Key + " }}"); } else if (col.Value == typeof(string)) { detail.AddColumn(col.Key, "{{ item." + col.Key + " }}"); } else if (col.Value == typeof(Nullable <decimal>) || col.Value == typeof(decimal)) { detail.AddColumn(col.Key, "{{ fn_FormatNumber item." + col.Key + " }}"); } else if (col.Value == typeof(Nullable <long>) || col.Value == typeof(long)) { detail.AddColumn(col.Key, "{{ fn_FormatNumber item." + col.Key + " }}"); } else if (col.Value == typeof(Nullable <bool>) || col.Value == typeof(bool)) { detail.AddColumn(col.Key, "{{ item." + col.Key + " }}"); } } } }