
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
tbc-common-grid
Advanced tools
`import CommonGridContainer from "tbc-common-grid/dist/Component/CommonGridContainer";`
import CommonGridContainer from "tbc-common-grid/dist/Component/CommonGridContainer";
<CommonGridContainer {...props} />
Object with each column (by dataField), each with own object with following props:
| Prop | Type | Required | Default | Description |
| ------------------- | -------- | -------- | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| title | String | Required | dataField | column header title |
| relativeWidth | Number | Optional | 1 | relative column width; used to determine column width relative to others columns |
| minWidth | Number | Optional | 0 | minimum pixel width that column cannot be smaller than |
| align | String | Optional | "left" | alignment of contents of column ("left", "center", or "right") |
| compare | Function | Optional | | comparison function used for column sorting |
| getCellValue | Function | Optional | () => return dataFieldValue
| function used to translate dataField into a different visual value; this could a dictionary translation of code to name, a mathematical calculation, etc. |
| showWhenGrouped | Boolean | Optional | false | if set to true, column will show even if grouped by that column |
| sortingEnabled | Boolean | Optional | true | | if set to false, sorting for column is disabled. |
Example 1:
columnsConfig: {
firstColumn: {
title: "First Column",
relativeWidth: 1,
minWidth: 100,
align: "right"
}
};
Example 2:
columnsConfig => props => {
const { dictionary } = props;
return {
firstColumn: {
title: "First Column",
relativeWidth: 1,
minWidth: 100,
align: "right",
compare: customCompareFunction
},
secondColumn: {
title: "Second Column",
relativeWidth: 1.5,
minWidth: 150,
getCellValue: row => {
return dictionary.columnCodes[row.secondColumn].name;
}
}
}
};
Array of data objects to be displayed in grid.
NOTE: For best results with sorting, derived fields (fields created from either multiple other fields or have heavy dictionary-based manipulations) should be included as part of these data objects.
OPTIONAL: Object of field_names, each containing an object:
type {String: "includes", "excludes", "range", "dateRange"}: determines what type of filtering takes place [default: "includes"]:
values {Array}: values to be filtered against; if empty, then no filter is applied for that field.
Example:
The following will return only items with a "firstColumn" value of "One". Because the "secondColumn" filter is empty, items with any secondColumn value (as long as they have firstColumn value of "One") will be displayed. If "secondColumn.values" array wasn't empty, because it's type is "excludes", any item contain secondColumn value of any of those items would be filtered out.
const filters = {
firstColumn: { values: ["One"] },
secondColumn: { type: "excludes", values: [] }
};
Object containing configuration options for the grid. All are optional.
defaultSorting {Array}: array of columnName/direction objects that determine default sorting; if empty, then no sorting is applied [default: null]
sortingArray
arrayonSortingChange(sortingArray)
functioncolumnReorderable {Boolean}: are columns reorderable [default: false]
isRowDraggable(row)
functionenableCheckboxes {Boolean}: provide table and row checkboxes
checkBoxFuncs
objectcheckboxSpacer: { title: " ", relativeWidth: 0.4, minWidth: 45 }
enableDetailRow {Boolean}: do rows have detail rows
detailSpacer: { title: " ", relativeWidth: 0.4, minWidth: 45 }
enableRowSelection {Boolean}: are rows selectable [default: false]
selectRow(row)
functiongrouping {Array}: array of columnName objects that determine default grouping; if empty, then no grouping is applied [default: null]
groupList
arrayheight {Number}: if non-zero, sets height for virtual table
pagination {object}: if exists, pagination is available:
Prop | Type | Default | Description |
---|---|---|---|
defaultCurrentPage | Number | 0 | zero-index page number |
defaultPageSize | Number | 10 | number of items shown |
pageSizes | Array | [] | array of available page sizes |
required prop: paginationObj
object
WARNING: It is not recommended to have Pagination enabled if Grouping is enabled (it is best to have only one or the other).
rowReorderable {Boolean}: are rows reorderable [default: false]
drag: { title: " ", relativeWidth: 0.4, minWidth: 45 }
sortingArray
and onSortingChange
become required functionsstaticColumnWidth {Boolean}: if set to true, columns will NOT be resizable [default: false]
hideHeader {Boolean}: if set to true, the table header row will not be displayed [default: false]
defaultExpandedRowIndices {Array}: Array of indices of the detail rows that should be expanded by default [default: [] ]
Numerical value for the width of the grid (in pixels), used with relativeWidth to dynamically determin column widths
Array of columns names that are displayed, and in what order
Optional function that receives row
value and returns a string of CSS classes that can be applied to the row.
Example: The following will apply the class "color-warning" to any row with a status value of "warning", else it will apply class "color-safe":
<CommonGridContainer
getRowClass={row => {
if (row.status === "warning") {
return "color-warning"
}
return "color-safe"
}}
/>
NOTE: This module contains the built-in classes: bg-blue, bg-red, bg-green, bg-yellow, and bg-grey (for appropriately colored background); any other styles will need to be assessible by the parent component.
Object of functions used if table has enableCheckboxes set to true:
Object used if columnReorderable is enabled:
Array of values that, when grouping is enabled, determine which groups are expanded by default.
Function used in rowReordering to return if row should be draggable or not [default: () => return true]
Function fired when sorting is performed
If using external pagination (either store-based or api-based), pass this object into the component:
Function called when right-click reorder menu selection made; returns row and "first" or "last"
rightClickReordering: (row, moveTo) => {
console.log("rightClickReordering:", row, moveTo);
}
JSX Element used as detail row; receives rowProps.row props
const ThisRowDetail = rowProps => {
const { row } = rowProps;
return (
<div>{JSON.stringify(row)}</div>
);
};
Function fired when row is selected; returns row
selectRow: row => {
console.log("selectRow:", row);
}
Function used to set/change data (rows) at parent level when changed in common grid.
Array of sorting objects (columnName/direction); used if sorting is stored external to common grid.
Array of row ids corresponding to which row has been expanded (when using RowDetail).
Function used to set/change data (row ids) for expanded rows (when using RowDetail).
import { getFilteredData } from "{path}/CommonGrid/Utils/commonGridUtils";
npm install --save @material-ui/icons @devexpress/dx-react-core @devexpress/dx-react-grid @devexpress/dx-react-grid-material-ui @material-ui/icons
) https://devexpress.github.io/devextreme-reactive/react/grid/npm install --save react-sortable-hoc
) https://github.com/clauderic/react-sortable-hocnpm install --save react-contextmenu
) https://www.npmjs.com/package/react-contextmenunpm install array-move
) https://www.npmjs.com/package/array-moveimport SampleComponentContainer from "tbc-common-grid/dist/Sample/SampleComponentContainer";
For any unit test file that deep renders ("mounts") this imported component, add the following:
jest.mock("tbc-common-grid/dist/Component/CommonGridContainer", () => "div");
FAQs
`import CommonGridContainer from "tbc-common-grid/dist/Component/CommonGridContainer";`
We found that tbc-common-grid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
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.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.