Git Product home page Git Product logo

blazortransfer's Introduction

BlazorTransfer

A JavaScript free Transfer (Dual List) library for Blazor applications

NuGet Status

gif of component in action

Getting Setup

You can add them searching BlazorTransfer in the Nuget Package Manager or from command line by running dotnet add package BlazorTransfer

Add Imports

Add the following to your _Imports.razor

@using TransferBlazor

Wiki

  • DataSource (required) - The source of data.
  • ValueProperty (required) - The name of the property that contains the value.
  • TextProperty (required) - The name of the property that contains the display text.
  • @bind-Value (required) - To bind a list where the ValueProperty of the items of the target table will go.
  • ShowSearch (optional) - Show a field to search. (Default value: false)
  • SearchPlaceholder (optional) - Change the placeholder text in the search field. (Default value: Type to search)
  • HeaderText (optional) - Change the header text. (Default value: items)
  • Change (optional) - Change event of the Transfer. Selected value as event argument.

Example

@page "/fetchdata"

@inject WeatherForecastService ForecastService

@if (_forecasts == null)
{
    <p><em>Loading...</em></p>
}
else
{
    <BlazorTransfer @bind-Value="_selectedItems" 
                    TItem="int"
                    DataSource="_forecasts" 
                    ValueProperty="TemperatureC" 
                    TextProperty="Summary" 
                    ShowSearch="true"                   
                    Change="(args) => Change(args)" />

    @foreach(var item in _events)
    {
        <span>@item</span>
        <br />
    }
}

@code 
{
    WeatherForecast[] _forecasts;
    List<string> _events = new List<string>();

    IEnumerable<int> _selectedItems = new List<int> { 1, 2, 3 }; //Is int because TemperatureC (ValueProperty) is int too

    protected override async Task OnInitializedAsync()
    {
        _forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
    }

    void Change(IEnumerable<int> args)
    {
        _events.AddRange(args.Select(x => x.ToString()));
    }
}

blazortransfer's People

Contributors

jusaan avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.