New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@spflow/grid

Package Overview
Dependencies
Maintainers
0
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spflow/grid

SharePoint Grid

latest
Source
npmnpm
Version
0.2.2
Version published
Maintainers
0
Created
Source

SPFlow Grid for SharePoint

Reusable declarative grid component for SharePoint List views applications.

The component is based on Fluent UI (former Office UI Fabric).

Supported platforms

  • SharePoint Online
  • SharePoint On-Prem (2019, 2016, 2013)

Main features

  • Declarative settings for most use-cases scenarios
    • List data source
    • OData, REST API projection (select, filter, top, expand, orderBy)
    • Columns model
  • Custom cell renderers
  • Embed and custom commands
  • Data enrichment
  • Columns runtime sorting
  • Grid columns customizable filter pane
  • True pagination
  • Export to Excel

Install

npm i @spflow/grid

Usage sample

import * as React from 'react';
import { GridView } from '@spflow/grid';

export const Component = (): JSX.Element => {

  return (
    <GridView
      listUri='_catalogs/masterpage'
      select='Id,Title,Editor/Title'
      expand='Editor'
      columns={[
        {
          key: 'Id',
          fieldName: 'Id',
          name: 'ID',
          minWidth: 40,
          maxWidth: 50
        },
        {
          key: 'Title',
          fieldName: 'Title',
          name: 'Title',
          minWidth: 150,
          maxWidth: 250
        },
        {
          key: 'Editor',
          fieldName: 'Editor/Title',
          name: 'Editor',
          minWidth: 150,
          maxWidth: 250
        }
      ]}
      commands={[
        { key: 'view' }
      ]}
      top={10}
    />
  );

};

Grid API Reference

Required properties

ParameterDescription
listUriSharePoint List URL, e.g. 'Lists/MyList', should not contain web relative URL
selectOData (REST API) field names to select and use in the grid, not necessarily should be presented in a view explicitly

List API query properties (optional)

ParameterDescription
filterOData (REST API) filter condition applied to grid view
expandOData (REST API) expand fields, e.g. a lookup field 'Editor' if 'Editor/Id,Editor/Title' is considered in select property
topOData (REST API) top number defines view page size
orderByOData (REST API) fields default sort constructor array, each object is { fieldName: string; ascending: boolean; }

Grid properties (optional)

ParameterDescription
titleView title, a text shown above grid component
showBackButtonIf true view back button is rendered
columnsColumns configuration model (see more below)
commandsCommand bar actions configuration model (see more below)
filterFieldsEnabled grid filters configuration model (see more below)
rendersCustom cell renderers collection object
onSelectionChangedGrid items selection change callback handler
reloadKeyWhen a new unique key is provided externally, grid refreshes itself
viewModeWhen true default edit commands are blocked
selectionModeFluentUI selection mode property bypass
enrichDataOnPageLoadData enrichment callback, can be used to request additional data after a page items loaded, e.g. request external API or something which is not possible to retrieve using standard OData approach
commandsCustomRulesCustom rules callback collection, the rules can be used in Commands enable option, allows action enable based on metadata or external conditions
emptyGridMessageMessage shown when no items are in the grid view response
viewStorageKeyUnique string used for local storage to persist grid state (applied filters, sort conditions, etc.) so these can be kept after a page reload

Columns model properties

Extends FluentUI IColumn interface.

ParameterDescription
fieldNameOData field name, maps API data and default view cell renderer, e.g. Title or Lookup/Title (required)
typeType renderers helper, allows rendering Boolean, Date, DateTime values without providing a custom renterer but reusing default embed helpers
disableSortIf true sorting by a column is disabled, must to applied for column types which do not support sorting (e.g. Note field)

Other properties are a bypass of FluentUI Details List IColumn interface, see more.

The required by FluentUI columns are: key, name, minWidth.

Filters model properties

ParameterDescription
labelFilter label
fieldNameOData (REST API) field name, some cases might also require adding corresponding expand and select values to the grid properties
fieldTypeCan be one of the following: 'string', 'number', 'date', 'lookup', 'boolean'
dictionaryA dictionary of values which can be selected in the filter, can be used together with 'string', 'number' and 'boolean' fieldTypes
lookupPropsLookup configuration object, is relevant only with 'lookup' fieldType, lookup props allows not only define which list to use, but also provide some options

Commands model properties

Extends FluentUI ICommandBarItemProps interface.

ParameterDescription
enableRuleString of |-separated rules which define if an action is enabled for the selected item(s) in a view
showRuleSame as enableRule but hides an action button instead of disabling
onClickHandlerAction handler

There are some predefined actions, such as 'add', 'copy', 'view', 'edit', 'delete'. These commands can be added in a simplified way by a shortcut declaration, e.g. { key: 'view' } will add the default view action button.

A sample of a rule:

enableRule: `onSingleSelection|permissions:${PermissionKind.EditListItems}|custom:myRule`

To operate with permissions, EffectiveBasePermissions property should be selected along with other fields in a grid definition.

Enable/show rules

Rules are declarative, within default rules are the following:

RuleDescription
onSingleSelectionWhen only a single item is selected in a view
onMultipleSelectionWhen multiple items are selected in a view
onAnySelectionWhen one or many items are selected in a view
permissions:[PermissionKind]Based on permissions where [PermissionKind] is permissions bit (see more)
custom:[CustomRule]Where [CustomRule] is a callback rule defined in commandsCustomRules

Keywords

sharepoint

FAQs

Package last updated on 22 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts