dohooo / react-native-table-component

🌱Build table for react native
MIT License
730 stars 188 forks source link

How to hide a cell or a column. #137

Open kelvindominguez1595 opened 3 years ago

kelvindominguez1595 commented 3 years ago

I am trying to hide a cell or the entire column since it will contain a unique identifier that is the ID of a record, could you help me?

RichMatthews commented 3 years ago

+1 I need this too

kelvindominguez1595 commented 3 years ago

there was no response ...

mcatal commented 2 years ago

Hi, I'm using like this,

const [tableData, setTableData] = React.useState({ tableHead: ["Hiding Head","Head 1", "Head 2", "Head 3"], tData: comeData, <--- your array data });

const TableCont = (item: any) => {

  const element = (data: any, index: any) => {

    if(index === 0)
    {
      return false;

    }else if(index === 1){

       return (
          <TouchableOpacity onPress={() => console.log('data : ',data)} >
            <Text style={style.rowTextStyleFirst}>{data}</Text>
          </TouchableOpacity>
      );

    }else{
      return <Text style={style.rowTextStyleFirst}>{data}</Text> 
    }

  }

  let flexArr=[-1, 3, 1, 1];

  return (
    <Table borderStyle={style.tableStyle}>
      <Row
        flexArr={flexArr}
        data={tableData.tableHead}
        style={style.headStyle}
        textStyle={style.headTextStyle}
      />
      {comeData.map((rowData: any, index: any) => (
        <TableWrapper key={index} style={style.rowStyle}>
          {rowData.map((cellData: any, cellIndex: any) => (
            <Cell
              key={cellIndex}
              flex={flexArr[cellIndex]}
              textStyle={style.rowTextStyle}
              data={element(cellData, cellIndex)}
            />
          ))}
        </TableWrapper>
      ))}
    </Table>
  );

};

Maybe it helps