首页 > 解决方案 > 如何使用 jquery 过滤数据表并添加值

问题描述

我正在使用 Datatable,我试图在文本红色或白色值的最后一个 td 列上过滤值..

当我点击箭头的过滤器时,什么都没有发生(没有过滤器操作)..

你知道为什么吗?

图像示例

 $('#sst-table-all-contracts').DataTable 
                            ({
                            'createdRow': function (row, data) {
                                $(row).find("td:eq(1)").attr("id", data[6]);
                                
                                if (data[7] == null )
                                {
                                    $(row).find('td:last').css("background", "white");
                                    $(row).find('td:last').text("white");
                                    $(row).find('td:last').css("color", "white");

                                }
                                else {
                                
                                    $(row).find('td:last').css("background", "red");
                                    $(row).find('td:last').text("red");
                                    $(row).find('td:last').css("color", "red");
                                
                                }
                                
                                },
                            "aaData": contractsList,
                            "aoColumns": [ {}, {}]

                                  });

标签: datatable

解决方案


推荐阅读