DataTable -> Column -> expander

UI Components for React
Post Reply
aokieh
Posts: 3
Joined: 20 Jul 2013, 15:16

10 Jan 2018, 17:33

hi,

i use primereact 1.4.0

the expander should not be visible in all rows.
the expander should only shown, if the value in the model is true.

Code: Select all

        let data = [
            {"rowvalue": true, ...},
            {"rowvalue": false, ...}];
            
            <DataTable value={this.props.data}
                       onRowToggle={(e) => this.setState({expandedRows:e.data})}
                       rowExpansionTemplate={(e) => this.rowExpansionTemplate(e)}
                       expandedRows={this.state.expandedRows}>
                <Column expander={rowvalue} style={{width: '3em'}} />
                <Column field="anyvalue" header="AColumn" />
            </DataTable>
can anybody help my?

thanks,
aokieh

merve7
Posts: 861
Joined: 12 Sep 2017, 10:44

26 Feb 2018, 10:56

You can use map(https://reactjs.org/docs/lists-and-keys.html) function to access rowvalue or use if statement for example

Code: Select all

<Column expander={your_case?true:false} style={{width: '3em'}} />

domehead100
Posts: 2
Joined: 28 Mar 2018, 18:31

28 Mar 2018, 19:20

I have no idea what you mean. If I'm doing

Code: Select all

<Column expander={this.isExpandable} />
and I have a class method

Code: Select all

isExpandable = (rowData, column) => {
   // return boolean based on rowData
  }
the callback never gets called. Are you suggesting we render something into the column that we can then pull off of the DOM element via a ref to look up the row (e.g., like one would do in jQuery)? We can't do that because an expander does not allow custom rendering.

I'm not seeing how map applies here since I'm just specifying a column definition, not a collection of rows.

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests