public void SetupColumns(IEnumerable <SearchItem> items, SearchColumnFlags options) { var fields = new HashSet <SearchField>(); foreach (var e in items ?? GetElements()) { fields.UnionWith(e.GetFields().Where(f => f.value != null)); } if (m_TableConfig != null && fields.Count > 0) { m_TableConfig.columns = fields.Select(f => ItemSelectors.CreateColumn(f.label, f.name, options: options)).ToArray(); SetSearchTable(m_TableConfig); } else { SetSearchTable(LoadDefaultTableConfig(reset: true)); } }
public void SetupColumns(IList <SearchField> fields) { SearchTable tableConfig = GetSearchTable(); var columns = new List <SearchColumn>(tableConfig.columns.Where(c => { var fp = fields.IndexOf(new SearchField(c.selector)); if (fp != -1) { if (!string.IsNullOrEmpty(fields[fp].alias)) { c.content.text = fields[fp].alias; } else if (fields[fp].value is string alias && !string.IsNullOrEmpty(alias)) { c.content.text = alias; } fields.RemoveAt(fp); return(true); } return((c.options & SearchColumnFlags.Volatile) == 0); })); foreach (var f in fields) { var c = ItemSelectors.CreateColumn(f.label, f.name); c.options |= SearchColumnFlags.Volatile; columns.Add(c); } if (columns.Count > 0) { tableConfig.columns = columns.ToArray(); SetSearchTable(tableConfig); } }