AI OnAI Off
Can you provide bit more detail on what you are trying to achieve ? Maybe some screenshots / diagrams so we can better understand
Vaibhav,
It sounds like you want to implement an Auto Suggestion property within the CMS editor interface, have you tried following this documentation:
The below code has the same logic as Mark mentioned but I have created a searchable dropdown in one of my commerce projects so maybe that code will help.
[ServiceConfiguration(typeof(ISelectionQuery))]
public class SearchOrganizatonsSelectionQuery: ISelectionQuery
{
public ISelectItem GetItemByValue(string value)
{
var val = value.Replace("%20", " "); // if the name contains blank spaces e.g. 'searchable dropdown' then replace the value else it will not be display as selected
return GetItemsInternal(val)?.FirstOrDefault();
}
public IEnumerable<ISelectItem> GetItems(string query)
{
return GetItemsInternal(query);
}
IEnumerable<ISelectItem> GetItemsInternal(string query)
{
return Task.Delay(500) //Provide buffer time to type the query completely else modify this code as per requirement
.ContinueWith(task => Search(query))
.Result;
}
IEnumerable<ISelectItem> Search(string query)
{
// Replace the below code as per your requirement
var filter = new FilterElement(OrganizationEntity.FieldName, FilterElementType.Contains, query?.Trim());
var response = (ListResponse)BusinessManager.Execute(new ListRequest(OrganizationEntity.ClassName, new[] { filter }, null, null, 50));
var orgList = response.EntityObjects?.OfType<Organization>()?
.OrderBy(x => x.Name)?
.ToList();
if (orgList != null)
{
foreach (var org in orgList)
{
yield return new SelectItem { Text = org.Name, Value = org.Name };
}
}
yield return new SelectItem { Text = "", Value = "" };
}
}
How can I create a selection factory with seach option in cms edit view