Mui数据表上的selectRow [英] selectRow on Mui Datatable

查看:61
本文介绍了Mui数据表上的selectRow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在React中首次尝试使用MUI-Datatables.我想从复选框中选择的行中获取数据.

This is my first try with MUI-Datatables in React. I want to get the data out of the Row i select on the Checkbox.

 const options = {

         download: false,
         print: false,
         viewColumns: false,
         filterTable: false,
         filter: false,
         onRowsSelect:(currentRowsSelected: any, allRowsSelected: any) => {console.log(allRowsSelected);}

     };

这仅给我所选行的索引.有没有一种方法来获取其行的数据.我需要该行的第一个单元格来删除/更新数据库.有谁能够帮我谢谢你.

This gives me only the index of selected row. Is there a way to get the data of its row. I need the first cell of the row to delete/update with the database. Can anybody help me Thank you.

推荐答案

即使在选项中也需要使用onRowClick

You need use onRowClick even in options

const options = {
    filterType: 'dropdown',
    responsive: 'scrollFullHeight',
    serverSide: true,
    count: total,
    page: page,
    onRowClick: handleRowClick,
}

并将此选项传递到MUI数据表

and pass this option into MUI DataTable

<MUIDataTable
   title={"Service Request List"}
   data={requests}
   columns={columns}
   options={options}
/>

这是行点击处理程序:

const handleRowClick = (rowData, rowMeta) => {
    console.log(rowData, rowMeta);
};

这篇关于Mui数据表上的selectRow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆