【发布时间】:2022-02-11 16:33:10
【问题描述】:
请帮助我,当用户按下 ctrl + 左键单击表格行应该突出显示该行时,我不知道如何解决该问题,而在 shift + 左键单击它应该突出显示用户从 1 行单击的所有行数据到 2 最后一行(例如 react-Table 多行选择)。 不使用任何 3 方库。
代码:-
const ClickHighlight = (event, ID, ChannelName) => {
if (event.ctrlKey) {
}
if(event.shiftKey) {
console.log("helloShift");
}
}
return (
<div className="mainContent">
<div className="tableHeaderBody">
<div className="TableText">PlayList</div> <div className="ClossIcon"><FaCircle style={{ color: "#FC0000", width: "10px", height: "10px", alignItems: "right" }} /></div>
</div>
<div className="tableBody" >
<table className="table" id="tableStudent" data-multiple-select-row="true"
data-click-to-select="true">
<Header
headers={headers}
/>
<tbody>
{comments.map((comment) => {
return (
<tr key={comment.idx} tabIndex={comment.idx} className="border_bottom" onMouseDown={(e) => ClickHighlight(e, comment.ClipName, comment.ChannelName)}>
<td style={{ color: "white", width: "200px" }}>
<img src={`data:image/jpeg;base64,${base64}`} alt="Clip Thumbnail" width="50%" />
</td>
<td style={{ color: "white", width: "440px" }}>{comment.ClipName}</td>
<td style={{ color: "white", width: "250px" }}>{comment.SlugName}</td>
<td style={{ color: "white", width: "250px" }}>{comment.ChannelName}</td>
请帮忙。
【问题讨论】:
-
您是否尝试过将突出显示的行(或其 ID)保持在状态?这样您就可以在 clickhandler 中添加和删除它们
-
不 你能举个例子说明我该怎么做吗?请
标签: javascript node.js reactjs