MDBDataTable

Tanawat limsakul asked 5 years ago

For MDBDataTable with filter, inside the code contain both row and column . How can I use data.map to loop the information from database into rows not loop on the column.

expected result: More rows base on information on Database but only one column of header

enter image description here https://mdbootstrap.com/docs/react/tables/sort/


JoseDR120 answered 5 years ago

Hey try this,

let rows = [];

data.map(res => { rows.push({ city: item, city: item, city: item, [...ect] }); });

let DataTable = { columns: [ { label: 'Demo', field: 'demo', sort: 'asc', width: 150, }, ], }; DataTable.rows = rows;


Jakub Chmura staff premium commented 5 years ago

Hi @JoseDR120,Thank you for your answer!

@Tanawat limsakul please let me know if this example works in your case.

Best, Kuba


@JoseDR120 Thank you, this is the best solution that I want. This solution works on my projects perfectly :)


Jakub Chmura staff premium commented 5 years ago

I’m happy to hear that this solution works in your case!

Best, Kuba


Jakub Chmura staff premium answered 5 years ago

HI @Tanawat limsakul,

I'm not sure that I understand you correctly, but if you mean that you want to filter by rows that is not possible.

If you have not understood what you want to achieve, please clarify the question.

Best, Kuba


FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Closed

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.25.5
  • Device: Desktop
  • Browser: Chrome
  • OS: OSX
  • Provided sample code: No
  • Provided link: Yes