Comments (16)
@fnils So I wanted to try it out and see what using Value and ValueChanged was like, it's not an enjoyable experience!
<BlazoredTypeahead SearchMethod="GetPeopleLocal"
Value="SelectedPerson"
ValueChanged="OnValueChanged"
TValue="Person"
TItem="Person"
ValueExpression="@(() => SelectedPerson)"
ShowDropDownOnFocus="true"
placeholder="Search by first name...">
<SelectedTemplate Context="person">
@person.Firstname
</SelectedTemplate>
<ResultTemplate Context="person">
@person.Firstname @person.Lastname
</ResultTemplate>
</BlazoredTypeahead>
@code {
private void OnValueChanged(Person selectedPerson)
{
SelectedPerson = selectedPerson;
}
}
This is what you need to make it work.
from typeahead.
I'd go with a wiki, makes it a bit easier, I'll see what I can do later this week. I do want some input though, what should be in the wiki?
- Basic Usage
- Advanced Usage
- Best practises
- ... ?
from typeahead.
Also the docs say to add ref to "@using Blazored.Typeahead.Forms" but this causes an error. Only works if you use @using Blazored.Typeahead
from typeahead.
Sorry this was a hangover from the older version. I've updated the docs now.
from typeahead.
Thanks for the update! Also would be handy to have at least one example code snippet that could work out of the box. Current examples don't compile because there are missing models/references, etc.
from typeahead.
The examples in the readme are just for reference. If you want to see working code then you can checkout the sample applications in the repo.
I'm working on a full docs site for all the Blazored components but it's a large project.
from typeahead.
Got it, thanks. Understand it's a large effort, I appreciate the work that has gone into all of these components. Will try to contribute when I get to the level of being helpful!
from typeahead.
How does it work if I want to use Value and ValueChanged instead of bind-value?
I get an error after the change to Value and ValueChange.
Exception thrown: 'System.ArgumentNullException' in Microsoft.AspNetCore.Components.Forms.dll
Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer: Warning: Unhandled exception rendering component: Value cannot be null. (Parameter 'accessor')
from typeahead.
@fnils In all honesty I haven't used that method of binding before. Whats the use case for it?
from typeahead.
I want to invoke an async EventCallback when a value is changed and I wanted to have an await. But maybe I am going about it in the wrong way. It works as is (with the @bind-Value) so it not really a problem. But I got curious when got the error and couldn't find an example.
from typeahead.
Chris,
You may want to re-visit the documentation at https://chrissainty.com/getting-started-with-blazored-typeahead/
It still makes reference to @using Blazored.Typeahead.Forms
from typeahead.
@kiwiingenuity Yes, it's on my ever growing list of things to do :)
from typeahead.
I like the extension but the documentation is a bit behind. I don't understand what all the properties of the control do. I want OnValueChanged
the selected items with some other parameters added. I thought something like ValueExpression="@(() => SelectedPerson, "foo", "bar")"
from typeahead.
Got it working:
<BlazoredTypeahead SearchMethod="@SearchCodes"
Value="SelectedItem"
ValueChanged="@(e => OnValueChanged(e, product.ProductId))"
TValue="CodeItem"
TItem="CodeItem"
ValueExpression="@(() => SelectedItem)"
Debounce="500"
placeholder="Search something...">
<SelectedTemplate>
@context.prop1
</SelectedTemplate>
<ResultTemplate>
<div style="display: flex; flex-direction: row;">
<div style="width: 100px; flex: initial;">@context.prop1</div>
<div style="flex: 1;">@context.prop2</div>
<div style="flex: 1; text-align: right;">€ @context.prop3</div>
</div>
</ResultTemplate>
<NotFoundTemplate>
No results
</NotFoundTemplate>
</BlazoredTypeahead>
@{
private CodeItem SelectedItem;
private void OnValueChanged(CodeItem selected, Guid productId)
{
}
private async Task<IEnumerable<CodeItem>> SearchCodes(string searchText)
{
}
}
from typeahead.
I'd go with a wiki, makes it a bit easier, I'll see what I can do later this week. I do want some input though, what should be in the wiki?
* Basic Usage * Advanced Usage * Best practises * ... ?
- Link to working example
- Version changes or at least history of breaking changes
- Maybe examples with different types of binding and/or design patterns (this is what I am always complaining about with MS docs for UWP controls)
from typeahead.
I'm going to close this issue as the docs improvement are part of a wider issue covering all Blazored packages. The main tracker for this is https://github.com/Blazored/Home/issues/1
from typeahead.
Related Issues (20)
- [Question] Is there a way to programmatically select multiple items? HOT 1
- [Bug] When used in a child component in multiselect mode items not added when selected HOT 1
- Have a OnClose Option for the Dropdown list
- [Question] Are you able to just use strings for Value and date related bindings on the control?
- Two way binding
- Typeahead search text dissapearing from search box after displaying results in v 4.7.0 HOT 14
- [Feature Request] Option to disable deleting items with "Backspace" when using MultiSelect
- Method to Force results dropdown to close?
- how to Enable mutli line
- Laptop touchpad not selecting item in results
- Error in "Using complex types but only binding to a single property" HOT 1
- [Bug] - blazored-typeahead results hides behind the modal-footer
- [Bug] Typeahead inside Blazored.Modal search text erase with .NET 7.0 HOT 3
- [Question] How to Justify Dropdown Content
- [Bug] ArgumentNullException after pressing 'backspace' key
- Clicking typeahead inside MudTable in <MudTd> by MudBlazor not set to Focus
- [Bug] Multiple Pasting of text into the control causes app pool to crash
- WORK PAUSED - PLEASE READ BEFORE POSTING AN ISSUE HOT 1
- how to set category id for Searchmethod HOT 1
- Scroll in dropdown menu
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typeahead.