简体   繁体   English

材料表中可调整大小的列反应

[英]Resizable column in material-table react

I have been working on material-table for quite a while and I have looked for different options where I can provide functionality of drag the column to adjust width but to no success.我一直在研究材料表很长一段时间,我一直在寻找不同的选项,我可以提供拖动列以调整宽度但没有成功的功能。

I googled quite a lot on how I can achieve this functionality in react but to no success.我在谷歌上搜索了很多关于如何在反应中实现此功能但没有成功。

I was able to find other tables but all my modules are built on material-table.我能够找到其他表,但我所有的模块都建立在材料表上。

Drag and drop table in angular angular中的拖放表格

I have provided link for drag and drop in angular but I'm working on react and I couldn't find any thing on material-table for react.我已经在 angular 中提供了拖放链接,但我正在处理反应,我在材料表上找不到任何反应。

There is no code included here, as I couldn't find anything on it.这里没有包含代码,因为我在上面找不到任何东西。 Only static widths are available as it was no use for this condition.只有 static 宽度可用,因为它不适用于这种情况。

Let me know on how can I incorporate provided example into react or if there is any working example or whether it is possible or not.让我知道如何将提供的示例合并到反应中,或者是否有任何工作示例,或者是否可能。

So I found in their GitHub page there is a mention of resizable column by selecting true in options, but its not working for me yet.因此,我在他们的 GitHub 页面中发现通过在选项中选择 true 来提及可调整大小的列,但它对我还不起作用。

Resizable column material table official merial-table github Resizable column 材质表官方merial-table github

Material-table does now provide this capability. Material-table 现在确实提供了这种能力。 You need to use the following two options:您需要使用以下两个选项:

  • tableLayout of 'fixed', as need to turn off the default auto width setting 'fixed'的tableLayout,需要关闭默认的自动宽度设置
  • columnResizable of true columnResizable 为 true

from demo.js under demo directory in material-table来自material-table中demo目录下的demo.js

<MaterialTable
  ...
  options={{
    tableLayout: "fixed",
    columnResizable: true
  }}
/>

In current implementation you can shrink the column so you lose the ability to further change the columns width.在当前实现中,您可以缩小列,因此您无法进一步更改列宽。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM