首页 > 解决方案 > 如何使用 MERN 堆栈获取已在列表中选择的卡的 ID?

问题描述

我正在开发一个 CRM 应用程序,并且我设计了一个弹出窗口,其中所有员工姓名都在卡片中检索。此外,我使用 tabIndex 通过单击相应的卡来选择员工。我想知道如何获取所选员工的员工 ID。我为弹出和选择员工实现的代码如下:

<EmployeePopup trigger={buttonPopup} setTrigger={openPopup}>
            <div>
              <input
              type="text"
              placeholder="Search employees"
              className="boxSearch"
              onChange={e => setSearch(e.target.value)}>
              </input>
              <Searchicon/>
            </div>
            {filteredEmployees?.length >0?
              <div className="employee-list">
              {filteredEmployees.map(employee=>(
                <div class="card-style card-header" tabIndex="-1" id={employee._id}>
                
                {employee.firstName + " " + employee.lastName+" "}
                {/* <input type="checkbox" id ={employee._id} value={employee.firstName + " " + employee.lastName} style={{float:"right", marginTop:"5px"}}/> */}
                </div>
              ))}
            
            
              </div>
            :<div><i>No employees found</i></div>}
            

              <div>
              <button className="assign-btn">Assign</button>
              </div>
              
            
             
             
          </EmployeePopup>

标签: merndata-retrievalcard

解决方案


推荐阅读