刷新后数据表搜索为空,但过滤器处于活动状态(Data Table Search is Empty After Refresh but Filter is Active)
所以我认为这可能是数据表lib中的一个错误。 我只能使用jsfiddle中的示例代码重现这一点。
重新创建的步骤:
- 打开JS Fiddle链接https://jsfiddle.net/t4rphnuc/
- 点击“运行”
- 在页脚搜索框中(无关紧要)过滤数据表
- 再次单击“运行”或刷新页面(您需要执行两次步骤2-4,因为JSFiddle第一次不缓存数据表)
注意:数据表仍然保持过滤,但搜索字段现在都是空的。
有没有其他人看过这个或看到我在这里做错了什么?
这是javascript
<script src="js/jquery.js" type="text/javascript"></script> <script src="js/jquery.dataTables.js" type="text/javascript"></script> <script src='https://code.jquery.com/jquery-1.12.4.js'></script> <script src='https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js' type="text/javascript"></script> <script src='https://cdn.datatables.net/select/1.2.5/js/dataTables.select.min.js' type="text/javascript"></script> <script src='https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js' type="text/javascript"></script> <script src='https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js' type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { const table = $('#example').DataTable({ stateSave: true }); // Setup - add a text input to each footer cell $('#example tfoot th').each( function () { var title = $(this).text(); $(this).html( '<input type="text" placeholder="Search '+title+'" />' ); } ); // Apply the search table.columns().every( function () { var that = this; $( 'input', this.footer() ).on( 'keyup change', function () { if ( that.search() !== this.value ) { that .search( this.value ) .draw(); } } ); } ); } ); </script>
大多数代码都来自此链接https://datatables.net/examples/api/multi_filter.html
预期的功能是数据表应该在加载之间保存状态,并且搜索框应该在页面重新加载时重新加载过滤的文本。
So I think this might be a bug in the data tables lib. I was able to reproduce this using just their example code in jsfiddle.
Steps to recreate:
- Open JS Fiddle link https://jsfiddle.net/t4rphnuc/
- Click "Run"
- In a footer search box (doesn't matter which) filter the data table
- Click "Run" again or refresh the page (you'll need to do steps 2-4 twice because JSFiddle doesn't cache the data table the first time)
NOTE: The Data table still remains filtered but the search fields are now all empty.
Has anyone else seen this or see something I'm doing wrong here?
This is the javascript
<script src="js/jquery.js" type="text/javascript"></script> <script src="js/jquery.dataTables.js" type="text/javascript"></script> <script src='https://code.jquery.com/jquery-1.12.4.js'></script> <script src='https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js' type="text/javascript"></script> <script src='https://cdn.datatables.net/select/1.2.5/js/dataTables.select.min.js' type="text/javascript"></script> <script src='https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js' type="text/javascript"></script> <script src='https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js' type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { const table = $('#example').DataTable({ stateSave: true }); // Setup - add a text input to each footer cell $('#example tfoot th').each( function () { var title = $(this).text(); $(this).html( '<input type="text" placeholder="Search '+title+'" />' ); } ); // Apply the search table.columns().every( function () { var that = this; $( 'input', this.footer() ).on( 'keyup change', function () { if ( that.search() !== this.value ) { that .search( this.value ) .draw(); } } ); } ); } ); </script>
Most of the code was taken from this link https://datatables.net/examples/api/multi_filter.html
The expected functionality is that the data table should save state between loads and the search boxes should reload the filtered text when the page reloads.
原文:https://stackoverflow.com/questions/49878160
最满意答案
SELECT C.name, count(*) FROM client C JOIN test T on T.clientId = C.clientId and T.status= 'Fail' group by C.name having count(*) > 2
SELECT C.name, count(*) FROM client C JOIN test T on T.clientId = C.clientId and T.status= 'Fail' group by C.name having count(*) > 2
相关问答
更多-
如何执行复杂的sql语句并在数组中获取结果?(How to execute a complex sql statement and get the results in an array?)[2023-03-11]
通过简单地将序列本身包装在一个数组中,可以将Swift中的大多数序列解压缩到一个数组中: let stmt = db.prepare( "SELECT defindex, AVG(price) FROM prices " + "WHERE quality = 5 AND price_index != 0 " + "GROUP BY defindex " + "ORDER BY AVG(price) DESC" ) let rows = Array(stmt) 此时构建数据源 ... -
尝试这个 declare @Field1 int declare @Field2 int declare @FCalculated1 int declare @FCalculated2 int declare @FieldA int declare @FieldB int declare @FieldC int declare @FieldD int declare @FieldE int declare @Value1 int declare @Value2 int select @FCalculate ...
-
您在Players.pid周围的条件有Players.pid 。 它应该是 (Players.pid = 25 OR Players.pid = 87) 逻辑OR运算符结合了两个逻辑条件。 Players.pid = 25是有效条件,它评估为布尔值true或false 。 但87绝对不会评估布尔值。 You have an error in condition around Players.pid. It should be (Players.pid = 25 OR Players.pid = 87) ...
-
形成复杂的SQL语句(Forming a complex SQL statement)[2023-01-29]
您正在寻找LEFT JOIN而不是内部LEFT JOIN 。 这将返回第一个表上的所有值,无论它是否与第二个表中的值匹配。 至于问题二,看起来你需要一个导师表来加入以获得名称。 有一个存在吗? SELECT u.firstname, q.question, r.tutor_id, r.response, u2.firstname AS TutorName FROM response r LEFT JOIN question q ON q.id = r.question_id JOIN user u ON ... -
复杂的Yii SQL语句(Complex Yii SQL statement)[2022-01-14]
要获得您的查询,您应该可以执行以下操作: $criteria = new CDbCriteria(); $criteria->join = "INNER JOIN tags pt ON t.id=pt.post_id"; $criteria->addInCondition("pt.tag_id", array(10,13)); $criteria->group = "t.id"; $criteria->having = "COUNT(DISTINCT pt.tag_id) > 1"; $posts = ... -
复杂更新Sql语句(Complex Update Sql Statement)[2022-02-15]
UPDATE `value` SET `value` = $value WHERE item_id = $item_id AND user_id IN (SELECT id FROM `users` WHERE username = $username) 一定要清理你的数据库输入。 这只会更新,如果你想创建条目(我假设user_id和item_id是你的第二个表的组合主键),你可以使用replace into语句。 如果你需要,请告诉我,因为我认为这不是问题。 它可能没有那么高效,但我认为这并不重要,但 ... -
复杂的SELECT SQL语句(Complex SELECT SQL statement)[2022-04-29]
我认为你走在正确的轨道上。 我会使用表名,如: SubjectsPerClass 和 TeachersPerClass 然后我创建一个连接语句并将其保存为视图,然后从现在开始查询视图 SELECT * FROM `SubjectsPerClass` sc JOIN `Subject` s ON `s`.`id` = `sc`.`subject_id` JOIN `Class` c ON `c`.`id` = `sc`.`class_id` 然后,如果您正在使用phpMyAdmin,请单击最后 ... -
我也遇到过这个问题: 您可以将CASE放入SELECT中并为其命名,以便可以在ORDER BY中使用它。 relation = Foo.select("*, CASE WHEN foos.thing IS NOT NULL THEN 0 ELSE 1 END AS foo_order").order("foo_order ASC") I've had this problem too: You can put the CASE into the SELECT and name it so you c ...
-
一个复杂的sql语句(A complex sql statement)[2022-02-13]
SELECT C.name, count(*) FROM client C JOIN test T on T.clientId = C.clientId and T.status= 'Fail' group by C.name having count(*) > 2 SELECT C.name, count(*) FROM client C JOIN test T on T.clientId = C.clientId ... -
复杂删除SQL语句(Complex Delete SQL Statement)[2022-02-11]
SQL Server使用delete非常灵活。 无论select在哪里,都允许双重语法: DELETE FROM t1 FROM table t1 WHERE t1.V1 > t1.V2 and EXISTS ( SELECT * FROM table t2 WHERE t2.V1 = t1.V2 and t2.V2 = t1.V1 ) SQL Server is fairly flexible with delete. The ...