diff --git a/server/AyaNova/DataList/AyaDataList.cs b/server/AyaNova/DataList/AyaDataList.cs index 15ee103a..11c47a45 100644 --- a/server/AyaNova/DataList/AyaDataList.cs +++ b/server/AyaNova/DataList/AyaDataList.cs @@ -45,8 +45,6 @@ namespace AyaNova.DataList public Newtonsoft.Json.Linq.JArray GenerateListColumnsJSONFromListView(JArray listViewArray) { - - var ListViewFieldKeys = GetFieldListFromListView(listViewArray); var CustomFieldDefinitions = GetCustomFieldDefinitionsForList(); @@ -80,6 +78,16 @@ namespace AyaNova.DataList else { //insert specific type for this custom field + if (CustomFieldDefinitions.ContainsKey(o.LtKey)) + { + var customFieldType = CustomFieldDefinitions[o.LtKey]; + sb.Append($"\"cm\":\"{o.LtKey}\",\"dt\":{customFieldType}"); + } + else + { + //this is normal as there may not be a definition for a Custom field but it's been requested so just treat it like text + sb.Append($"\"cm\":\"{o.LtKey}\",\"dt\":{(int)UiFieldDataType.Text}"); + } } //Has a AyObjectType? (linkable / openable) @@ -110,11 +118,11 @@ namespace AyaNova.DataList //Find and return a dictionary of all custom fields definitions for all types in list //used to build the column array and define specific type defined for custom fields so client datatable //knows how to format it - private Dictionary GetCustomFieldDefinitionsForList() + private Dictionary GetCustomFieldDefinitionsForList() { //all keys and types can go in the same list since they are unique to each type of list //i.e. both users and widget custom fields can be in the same list - Dictionary ret = new Dictionary(); + Dictionary ret = new Dictionary(); List typesProcessed = new List(); //custom fields handling foreach (AyaDataListFieldDefinition d in this.FieldDefinitions) @@ -144,9 +152,11 @@ namespace AyaNova.DataList //iterate the fields and add each custom one with a type to the return dictionary var flds = JArray.Parse(fc.Template); - foreach(JToken t in flds){ - if(t["type"]!=null){ - ret.Add(t["fld"].Value(),t["type"].Value()); + foreach (JToken t in flds) + { + if (t["type"] != null) + { + ret.Add(t["fld"].Value(), t["type"].Value()); } }