Could you please provide some guidelines for AutoComplete component on how to pass a context object that is of for eg. IEnumerable customers type as a parameter within the OnChange method?
eg: @onchange="@OnChange(Customer)
Thanks in advance.
Hello korchev,
the following code gives me an error that says "The name 'clientobj' does not exist in the current context"
Could you please tell me if I am doing anything wrong here?
`
<RadzenAutoComplete @bind-Value ="@model.CustomerName" Data=@ClientAuditorList TextProperty="ClientName" FilterOperator="StringFilterOperator.StartsWith"
Change=@(args => OnChange(args, clientobj)) Style="width: 100%; font-size: 24px;" >
<Template Context="clientobj">
@clientobj.ClientName <br> @clientobj.AuditorName
</Template>
</RadzenAutoComplete>
Yes, clientobj is the context of the template and can't be used outside of it. I would suggest something else - don't set TextProperty. Then the argument of the change event will be the current data item (you will have to cast it to your target type). Also @bind-value
should be @bind-Value
.
Hi Korchev, Many thanks for the quick response. Still no luck. I am getting this error now. The Context="clientobj" is of LtrAudClientAuditorList type. please advise.
What exactly are you trying to achieve? We can't tell from the screenshot what your change handler is.
Here is my change handler, I trying to obtain the ClientName, AuditorId, and AuditorName from the clientobj context.
Then you can try removing @bind-Value
altogether. It is now trying to set it to a string property (because TextProperty has been removed).
I removed @bind-Value and now getting a different error. Are there any good examples that deal with context objects in Change event within AutoComplete component?
It seems you can't use it without TextProperty as then filtering won't work (this is the Contains problem). The context is not passed in the Change event - you will have to find the corresponding item by its CustomerName property.
Alright, Thanks for your suggestion.