将自定义按钮添加到jQuery DataTable中每一行的最后一列

问题描述

我正在尝试重新创建在Child Rows DataTables处找到的示例数据表

DataTables工作正常,我没有收到-“第0行第4列的请求的未知参数'4'”错误。 我的问题是该按钮未在最后一列中呈现。有人可以帮我解决这个问题,谢谢!

这是我的Java Servlet逻辑。

enter image description here

JavaScript代码

enter image description here

还有我的桌子-

                                <tr>
                                    
                                     <th>Employee</th>
                                     <th>Shift</th>
                                     <th>Start Date</th>
                                     <th>End Date</th>  
                                     <th>Details</th>
                                </tr>
                           </thead>
                           <tfoot>
                            <tr>
                                    
                                     <th>Employee</th>
                                     <th>Shift</th>
                                     <th>Start Date</th>
                                     <th>End Date</th>
                                     <th>Details</th>
                    
                           </tr>
                           
                           </tfoot>

解决方法

在render函数中,您需要返回一个字符串。因此,您只需要在按钮定义前后添加一个单引号,例如'<button>Click Here!</button>';