lara-light-indigo

OrderList

OrderList is used to sort a collection.

List of Products
    Import via Module
    
    import { OrderList } from 'primereact/orderlist';
     
    Import via CDN
    
    <script src="https://unpkg.com/primereact/core/core.min.js"></script>
    <script src="https://unpkg.com/primereact/orderlist/orderlist.min.js"></script>
     
    Getting Started

    OrderList requires an array as its value, a template for its content where each item in the array can be accessed inside the template and onChangecallback to update the value after reorder.

    
    <OrderList value={products} itemTemplate={itemTemplate} header="Products" onChange={(e) => setProducts(e.value)}></OrderList>
     
    DragDrop

    Items can be reordered using drag and drop by enabling dragdrop property.

    
    <OrderList value={products} itemTemplate={itemTemplate} dragdrop onChange={(e) => setProducts(e.value)}></OrderList>
     
    Filtering

    Items can be filtered using an input field by enabling the filter property. By default filtering is done against label of the items and filterBy property is available to choose one or more properties of the options. In addition filterMatchMode can be utilized to define the filtering algorithm, valid options are "contains" (default), "startsWith", "endsWith", "equals" and "notEquals".

    
    <OrderList value={products} filter filterBy="name" />
     
    Custom Content

    For custom content support define an itemTemplate function that gets the item instance as a parameter and returns the content. For custom filter support define a filterTemplate function that gets the option instance as a parameter and returns the content for the filter element.

    
    const [filterValue, setFilterValue] = useState('');
    const filterInputRef = useRef();
    
    const itemTemplate = (item) => {
        // custom content
    }
    
    const filterTemplate = (options) => {
        let {filterOptions} = options;
    
        return (
            <div className="flex gap-2">
                <InputText value={filterValue} ref={filterInputRef} onChange={(e) => myFilterFunction(e, filterOptions)} />
                <Button label="Reset" onClick={() => myResetFunction(filterOptions)} />
            </div>
        )
    }
    
    const myResetFunction = (options) => {
        setFilterValue('');
        options.reset();
        filterInputRef && filterInputRef.current.focus()
    }
    
    const myFilterFunction = (event, options) => {
        let _filterValue = event.target.value;
        setFilterValue(_filterValue);
        options.filter(event);
    }
     
    
    <OrderList value={products} header="List of Products" dataKey="id" itemTemplate={itemTemplate} filter filterBy="name" filterTemplate={filterTemplate}></OrderList>
     
    Properties
    NameTypeDefaultDescription
    idstringnullUnique identifier of the element.
    valuearraynullAn array of objects to reorder.
    dataKeystringnullName of the field that uniquely identifies the a record in the data.
    headerstringnullText for the caption
    stylestringnullInline style of the element.
    classNamestringnullStyle class of the element.
    listStylestringnullInline style of the list element.
    dragdropbooleanfalseWhether to enable dragdrop based reordering.
    dragdropScopestringnullUnique key of drag drop events to avoid conflict with other drag drop events on the page.
    itemTemplatefunctionnullFunction that gets an item in the list and returns the content for it.
    filterTemplateanynullThe template of filter element.
    filterbooleanfalseWhen specified, displays an input field to filter the items on keyup.
    filterBystringlabelWhen filtering is enabled, filterBy decides which field or fields (comma separated) to search against.
    filterMatchModestringcontainsDefines how the items are filtered, valid values are "contains" (default), "startsWith", "endsWith", "equals" and "notEquals".
    filterPlaceholderstringnullPlaceholder text to show when filter input is empty.
    filterLocalestringundefinedLocale to use in filtering. The default locale is the host environment's current locale.
    tabIndexnumbernullIndex of the element in tabbing order.
    Events
    NameParametersDescription
    onChangeevent.originalEvent: Browser event
    event.value: Reordered list
    Callback to invoke when list is reordered.
    onFilterevent.originalEvent: Original event
    event.filter: Value of the filter input
    Callback to invoke when the value is filtered.
    Methods
    NameParametersDescription
    resetFilter-Reset the options filter.
    Styling

    Following is the list of structural style classes, for theming classes visit theming page.

    NameElement
    p-orderlistContainer element.
    p-orderlist-listList container.
    p-orderlist-itemAn item in the list
    p-orderlist-filter-containerContainer of filter input.
    p-orderlist-filterFilter element.
    p-orderlist-filter-iconFilter icon.
    Accessibility

    This section is under development. After the necessary tests and improvements are made, it will be shared with the users as soon as possible.

    Dependencies

    None.

    Component Scale

    Input Style

    Ripple Effect

    Free Themes

    Built-in component themes created by the PrimeReact Theme Designer.

    Bootstrap
    Blue
    Purple
    Blue
    Purple
    Material Design
    Indigo
    Deep Purple
    Indigo
    Deep Purple
    Material Design Compact
    Indigo
    Deep Purple
    Indigo
    Deep Purple
    Tailwind
    Tailwind Light
    Fluent UI
    Blue
    PrimeOne Design - 2022 NEW
    Lara Indigo
    Lara Blue
    Lara Purple
    Lara Teal
    Lara Indigo
    Lara Blue
    Lara Purple
    Lara Teal
    PrimeOne Design - 2021
    Saga Blue
    Saga Green
    Saga Orange
    Saga Purple
    Vela Blue
    Vela Green
    Vela Orange
    Vela Purple
    Arya Blue
    Arya Green
    Arya Orange
    Arya Purple
    Premium Themes

    Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.

    Soho Light
    Soho Dark
    Viva Light
    Viva Dark
    Mira
    Nano

    Legacy Free Themes

    Nova
    Nova Alt
    Nova Accent
    Luna Blue
    Luna Green
    Luna Amber
    Luna Pink
    Rhea

    Premium Create-React-App Templates

    Beautifully crafted premium create-react-app application templates by the PrimeTek design team.

    Sakai
    Atlantis
    Freya
    Ultima
    Diamond
    Sapphire
    Serenity
    Babylon
    Avalon
    Apollo
    Roma