diff --git a/content/app/development/ux/components/listComponent/_index.en.md b/content/app/development/ux/components/listComponent/_index.en.md index e6a5c21aaed..c13792f3f7a 100644 --- a/content/app/development/ux/components/listComponent/_index.en.md +++ b/content/app/development/ux/components/listComponent/_index.en.md @@ -55,10 +55,16 @@ public class ListCases : IDataListProvider { public string Id { get; set; } = "people"; - public async Task GetDataListAsync(string language, Dictionary keyValuePairs) + public Task GetDataListAsync(string language, Dictionary keyValuePairs) { int start = 0; int count = 10; + string search = ""; + + if (keyValuePairs.ContainsKey("search") ) + { + search = keyValuePairs["search"]; + } if (keyValuePairs.ContainsKey("size") && keyValuePairs.ContainsKey("page")) { @@ -82,6 +88,12 @@ public class ListCases : IDataListProvider items.Add(new ListItem { Name = "Karl", Age = 49, Profession = "Skuespiller" }); items.Add(new ListItem { Name = "Mette", Age = 33, Profession = "Artist" }); + + if (!String.IsNullOrEmpty(search)) + { + items = items.Where(o => (o.Name == search)).ToList(); + } + if (keyValuePairs.ContainsKey("sortDirection")) { string sortDirection = keyValuePairs["sortDirection"]; @@ -95,13 +107,14 @@ public class ListCases : IDataListProvider items.Reverse(); } } - + DataListMetadata appListsMetaData = new DataListMetadata() { TotaltItemsCount = items.Count }; - + List objectList = new List(); items.ForEach(o => objectList.Add(o)); - return new DataList { ListItems = objectList.GetRange(start, count), _metaData = appListsMetaData }; + int boundedCount = start + count > items.Count ? items.Count - start : count; + return Task.FromResult(new DataList { ListItems = objectList.GetRange(start, boundedCount), _metaData = appListsMetaData }); } } ``` diff --git a/content/app/development/ux/components/listComponent/_index.nb.md b/content/app/development/ux/components/listComponent/_index.nb.md index 5f28c090c1e..11dfd708001 100644 --- a/content/app/development/ux/components/listComponent/_index.nb.md +++ b/content/app/development/ux/components/listComponent/_index.nb.md @@ -55,10 +55,16 @@ public class ListCases : IDataListProvider { public string Id { get; set; } = "people"; - public async Task GetDataListAsync(string language, Dictionary keyValuePairs) + public Task GetDataListAsync(string language, Dictionary keyValuePairs) { int start = 0; int count = 10; + string search = ""; + + if (keyValuePairs.ContainsKey("search") ) + { + search = keyValuePairs["search"]; + } if (keyValuePairs.ContainsKey("size") && keyValuePairs.ContainsKey("page")) { @@ -82,6 +88,12 @@ public class ListCases : IDataListProvider items.Add(new ListItem { Name = "Karl", Age = 49, Profession = "Skuespiller" }); items.Add(new ListItem { Name = "Mette", Age = 33, Profession = "Artist" }); + + if (!String.IsNullOrEmpty(search)) + { + items = items.Where(o => (o.Name == search)).ToList(); + } + if (keyValuePairs.ContainsKey("sortDirection")) { string sortDirection = keyValuePairs["sortDirection"]; @@ -95,13 +107,14 @@ public class ListCases : IDataListProvider items.Reverse(); } } - + DataListMetadata appListsMetaData = new DataListMetadata() { TotaltItemsCount = items.Count }; - + List objectList = new List(); items.ForEach(o => objectList.Add(o)); - return new DataList { ListItems = objectList.GetRange(start, count), _metaData = appListsMetaData }; + int boundedCount = start + count > items.Count ? items.Count - start : count; + return Task.FromResult(new DataList { ListItems = objectList.GetRange(start, boundedCount), _metaData = appListsMetaData }); } } ```