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

[Solved] Autocomplete in a Column Template

0 Answers 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kuangyi
Top achievements
Rank 1
Kuangyi asked on 23 Sep 2011, 03:21 PM
Hi, in my grid, I have a column template that I want to put an autocomplete in.  I have to use a template because I need to represent dynamic columns that are figured out at run-time and .bound() doesn't bind to anything but properties and fields (whereas this is in a IEnumerable).

My code looks like this for that part of the grid; irrelevant parts taken out:

foreach (...)
        {
            ...
            
            columns.Template(
            @<div style="width:100px;">
                @{
                    string value = ...;
                    string keyName = ...;
                    string valueName = ...;
                  }
                <input id="@keyName" name="@keyName" type="hidden" value="@..." />
                <input style="width:inherit" id="@valueName" name="@valueName" value="@value" />
                @Html.Telerik().AutoComplete().
                    .Name(@valueName)
                    .DataBinding(binding => binding.Ajax().Select("AutoCompleteAjaxLoading", "...", new { ... }))
                    .AutoFill(true)
                    .HighlightFirstMatch(true)
                    .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.StartsWith));
                @{
                    ...
                }
            </div>
            ).Title(...).Width(100);
        }

I get an error:
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: key



And this occurs at at 
  @Html.Telerik().AutoComplete().

I'm not sure what the key parameter is.  Is this even possible?  I've only seen people do this in an EditorTemplate, however that would require quite a bit of a workaround for all the information that I need to use in the template.
Tags
Grid
Asked by
Kuangyi
Top achievements
Rank 1
Share this question
or