still torn apart but getting there at server, no client work done yet at all
This commit is contained in:
@@ -30,7 +30,7 @@ namespace AyaNova.DataList
|
||||
public long CurrentUserId { get; set; }
|
||||
|
||||
public List<string> DefaultColumns { get; set; }
|
||||
public List<string> DefaultSortBy { get; set; }
|
||||
public Dictionary<string, string> DefaultSortBy { get; set; }
|
||||
|
||||
//set defaults if not provided in listOptions
|
||||
public void SetListOptionDefaultsIfNecessary(DataListOptions listOptions)
|
||||
@@ -42,18 +42,18 @@ namespace AyaNova.DataList
|
||||
}
|
||||
|
||||
|
||||
//return array of field keys in list view
|
||||
public List<string> GetFieldListFromListView(JArray listViewArray)
|
||||
{
|
||||
// [{key:"COLUMN UNIQUE KEY ID",sort:"-" or "+",filter:{any:true/false,items:[{FILTER OBJECT SEE BELOW}]} }, {key:"second column unique key"},{...etc...}]
|
||||
List<string> ret = new List<string>();
|
||||
for (int i = 0; i < listViewArray.Count; i++)
|
||||
{
|
||||
var cm = listViewArray[i];
|
||||
ret.Add(cm["fld"].Value<string>());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
// //return array of field keys in list view
|
||||
// public List<string> GetFieldListFromListView(JArray listViewArray)
|
||||
// {
|
||||
// // [{key:"COLUMN UNIQUE KEY ID",sort:"-" or "+",filter:{any:true/false,items:[{FILTER OBJECT SEE BELOW}]} }, {key:"second column unique key"},{...etc...}]
|
||||
// List<string> ret = new List<string>();
|
||||
// for (int i = 0; i < listViewArray.Count; i++)
|
||||
// {
|
||||
// var cm = listViewArray[i];
|
||||
// ret.Add(cm["fld"].Value<string>());
|
||||
// }
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace AyaNova.DataList
|
||||
//BUILD THE COLUMNS RETURN PROPERTY JSON FRAGMENT
|
||||
Newtonsoft.Json.Linq.JArray ColumnsJSON = null;
|
||||
|
||||
ColumnsJSON = DataList.GenerateListColumnsJSONFromListView(listOptions.Columns);
|
||||
ColumnsJSON = DataList.GenerateListColumnsJSONFromListView(listOptions.Columns);//<<<-----this next
|
||||
|
||||
return new ApiDataListResponse(rows, totalRecordCount, ColumnsJSON);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace AyaNova.DataList
|
||||
|
||||
NEW:
|
||||
columns:["PartInventoryTransactionEntryDate","PartPartNumber","PartWarehouseName","PartInventoryTransactionQuantity","PartInventoryTransactionDescription","PartInventoryTransactionSource","PartInventoryBalance"]
|
||||
sortBy:[{"PartInventoryTransactionEntryDate":"-"}],//All sorted columns here as keyvalue pairs value is a string of "+" for ascending "-" for descending
|
||||
sortBy:[{"PartInventoryTransactionEntryDate":"-"}],//All sorted columns here as keyvalue pairs value is a string of "+" for ascending "-" for descending and are IN ORDER of how to be sorted
|
||||
filter:[{column:"PartPartNumber",any:true/false,items:[{op: "=",value: "400735"}]}],
|
||||
clientCriteria:"2" //could be anything here that makes sense to the list, in this case an example customer id for customernotedatalist
|
||||
*/
|
||||
|
||||
@@ -17,18 +17,20 @@ namespace AyaNova.DataList
|
||||
//iterate the datafilter and concatenate a sql query from it
|
||||
// [{key:"COLUMN UNIQUE KEY ID",sort:"-" or "+",filter:{any:true/false,items:[{FILTER OBJECT SEE BELOW}]} }, {key:"second column unique key"},{...etc...}]
|
||||
bool SortItemAdded = false;
|
||||
for (int i = 0; i < listViewArray.Count; i++)
|
||||
// for (int i = 0; i < listViewArray.Count; i++)
|
||||
foreach(KeyValuePair<string,string> kvSort in listOptions.SortBy)
|
||||
{
|
||||
var cm = listViewArray[i];
|
||||
//skip it if sort is not defined
|
||||
if (cm["sort"] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var fld = cm["fld"].Value<string>();
|
||||
var dir = cm["sort"].Value<string>();
|
||||
// var cm = listViewArray[i];
|
||||
// //skip it if sort is not defined
|
||||
// if (cm["sort"] == null)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// var fld = cm["fld"].Value<string>();
|
||||
// var dir = cm["sort"].Value<string>();
|
||||
|
||||
//Get the correct sql column name
|
||||
AyaDataListFieldDefinition DataListField = objectFieldsList.FirstOrDefault(z => z.FieldKey == fld);
|
||||
AyaDataListFieldDefinition DataListField = objectFieldsList.FirstOrDefault(z => z.FieldKey == kvSort.Key);
|
||||
//No sorting on custom fields!
|
||||
if (DataListField.IsCustomField)
|
||||
{
|
||||
@@ -38,7 +40,7 @@ namespace AyaNova.DataList
|
||||
//Developers little helper
|
||||
if (DataListField == null)
|
||||
{
|
||||
throw new System.ArgumentNullException($"DEV ERROR in DataListSqlFilterOrderByBuilder.cs: field {fld} specified in template was NOT found in ObjectFields list");
|
||||
throw new System.ArgumentNullException($"DEV ERROR in DataListSqlFilterOrderByBuilder.cs: field {kvSort.Key} specified in template was NOT found in ObjectFields list");
|
||||
}
|
||||
#endif
|
||||
var SQLValueColumnName = DataListField.GetSqlValueColumnName();
|
||||
@@ -49,7 +51,8 @@ namespace AyaNova.DataList
|
||||
sb.Append(" ");
|
||||
sb.Append(SQLValueColumnName);
|
||||
sb.Append(" ");
|
||||
sb.Append(dir == "+" ? "ASC" : "DESC");
|
||||
//sb.Append(dir == "+" ? "ASC" : "DESC");
|
||||
sb.Append(kvSort.Value == "+" ? "ASC" : "DESC");
|
||||
|
||||
SortItemAdded = true;
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ namespace AyaNova.DataList
|
||||
|
||||
//Defaults when none is specified (see DataListOptions for formats and notes)
|
||||
List<string> DefaultColumns { get; set; }
|
||||
List<string> DefaultSortBy { get; set; }
|
||||
Dictionary<string, string> DefaultSortBy { get; set; }
|
||||
|
||||
void SetListOptionDefaultsIfNecessary(DataListOptions listOptions);
|
||||
|
||||
Newtonsoft.Json.Linq.JArray GenerateListColumnsJSONFromListView(JArray listViewArray);
|
||||
List<string> GetFieldListFromListView(JArray listViewArray);
|
||||
// List<string> GetFieldListFromListView(JArray listViewArray);
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user