This is a migrated thread and some comments may be shown as answers.

Want field display different than filtered results

1 Answer 95 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 27 Mar 2019, 04:07 PM

I am working with AutoComplete in a grid cell. I need the dropdown display for the filter to be different than the value that populates the field once a value is selected. The stored procedure that returns the values to be searched/filtered combines several fields so the users can filter several fields at once. However, I don't want the final selected value displayed to be that field but another shortened field. In my example, the filtering is done on a combination of "ProjectNumber" and "ProjectName" while the final selected value displayed should only be the ProjectNumber.

This isn't an issue once the user presses the Bulk Save button on the grid as the read returns only the ProjectNumber for the grid field but I need to display only the ProjectNumber once an autocomplete value is selected.

@(Html.Kendo().AutoComplete()
        .Name("")
        .Filter(FilterType.Contains)
        .DataTextField("ProjectLookup")
        .Value("ProjectKey")
        .ValuePrimitive(true)
        .Placeholder("Select...")
        .Template("#= ProjectNumber # | #= ProjectName #")
        .AutoWidth(true)
        .MinLength(1)
        .DataSource(dataSource =>
        {
            dataSource.Ajax();
            dataSource.Read(read =>
            {
                read.Action("ProjectAutoComplete_Read", "Timecard").Data("projectAutoCompleteRead");
            })
            .ServerFiltering(false);
        })
        .Events(events => events
            .Select("projectAutoComplete_OnSelect")
            .Filtering("projectAutoComplete_OnFiltering")
            .Change("projectAutoComplete_OnChange")
        )
)

 

 

1 Answer, 1 is accepted

Sort by
0
Misho
Telerik team
answered on 01 Apr 2019, 01:06 PM
Hello,

Kendo Autocomplete has configuration for dataTextField, which is the text used when searching for suggestions and that will be displayed in the list of matched results: https://docs.telerik.com/kendo-ui/api/javascript/ui/autocomplete/configuration/datatextfield
On the other hand the Kendo Combobox, Dropdownlist and Multiselect have dataTextField that provides the text content of the list items and dataValueField that provides the value of the widget.

You could observe an implementation of Kendo Grid with custom combobox editor on the following ASP.NET Core online example:

https://demos.telerik.com/aspnet-core/grid/editing-custom 

I hope you will find this information useful.

Best Regards,
Misho
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
AutoComplete
Asked by
Mark
Top achievements
Rank 1
Answers by
Misho
Telerik team
Share this question
or