Skip to content
Snippets Groups Projects

Resolve TMSS-298

Merged Ramesh Kumar requested to merge TMSS-298 into master
5 files
+ 21
7
Compare changes
  • Side-by-side
  • Inline
Files
5
  • a0e7e072
    TMSS-298 - add default sorting · a0e7e072
    Muthu authored
    Added default sorting feature in table
@@ -229,7 +229,7 @@ const IndeterminateCheckbox = React.forwardRef(
@@ -229,7 +229,7 @@ const IndeterminateCheckbox = React.forwardRef(
)
)
// Our table component
// Our table component
function Table({ columns, data, defaultheader, optionalheader }) {
function Table({ columns, data, defaultheader, optionalheader, defaultSortColumn }) {
const filterTypes = React.useMemo(
const filterTypes = React.useMemo(
() => ({
() => ({
// Add a new fuzzyTextFilterFn filter type.
// Add a new fuzzyTextFilterFn filter type.
@@ -280,7 +280,8 @@ function Table({ columns, data, defaultheader, optionalheader }) {
@@ -280,7 +280,8 @@ function Table({ columns, data, defaultheader, optionalheader }) {
data,
data,
defaultColumn,
defaultColumn,
filterTypes,
filterTypes,
initialState: { pageIndex: 0 }
initialState: { pageIndex: 0,
 
sortBy: defaultSortColumn }
},
},
useFilters,
useFilters,
useGlobalFilter,
useGlobalFilter,
@@ -421,7 +422,11 @@ function ViewTable(props) {
@@ -421,7 +422,11 @@ function ViewTable(props) {
// Default Header to show in table and other columns header will not show until user action on UI
// Default Header to show in table and other columns header will not show until user action on UI
let defaultheader = props.defaultcolumns;
let defaultheader = props.defaultcolumns;
let optionalheader = props.optionalcolumns;
let optionalheader = props.optionalcolumns;
let defaultSortColumn = props.defaultSortColumn;
 
if(!defaultSortColumn){
 
defaultSortColumn =[{}];
 
}
 
let columns = [];
let columns = [];
let defaultdataheader = Object.keys(defaultheader[0]);
let defaultdataheader = Object.keys(defaultheader[0]);
let optionaldataheader = Object.keys(optionalheader[0]);
let optionaldataheader = Object.keys(optionalheader[0]);
@@ -508,7 +513,8 @@ function ViewTable(props) {
@@ -508,7 +513,8 @@ function ViewTable(props) {
return (
return (
<div>
<div>
<Table columns={columns} data={tbldata} defaultheader={defaultheader[0]} optionalheader={optionalheader[0]} />
<Table columns={columns} data={tbldata} defaultheader={defaultheader[0]} optionalheader={optionalheader[0]}
 
defaultSortColumn={defaultSortColumn} />
</div>
</div>
)
)
}
}
Loading