刷新后数据表搜索为空,但过滤器处于活动状态(Data Table Search is Empty After Refresh but Filter is Active)

所以我认为这可能是数据表lib中的一个错误。 我只能使用jsfiddle中的示例代码重现这一点。

重新创建的步骤:

  1. 打开JS Fiddle链接https://jsfiddle.net/t4rphnuc/
  2. 点击“运行”
  3. 在页脚搜索框中(无关紧要)过滤数据表
  4. 再次单击“运行”或刷新页面(您需要执行两次步骤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:

  1. Open JS Fiddle link https://jsfiddle.net/t4rphnuc/
  2. Click "Run"
  3. In a footer search box (doesn't matter which) filter the data table
  4. 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
2024-03-26 15:03

满意答案

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?)

通过简单地将序列本身包装在一个数组中,可以将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) 此时...

sql complex case用于计算字段的语句(sql complex case when statement for a calculated field)

尝试这个 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 @FCalc...

SQL使用“AND”+“OR”语句加入(SQL Join with “AND” + “OR” statement)

您在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 = ...

形成复杂的SQL语句(Forming a complex SQL statement)

您正在寻找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 ...

复杂的Yii SQL语句(Complex Yii SQL statement)

要获得您的查询,您应该可以执行以下操作: $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"; $po...

复杂更新Sql语句(Complex Update Sql Statement)

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)

我认为你走在正确的轨道上。 我会使用表名,如: 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,...

带轨道的复杂订单语句AREL:SQL Case语句(Complex order statement with rails AREL: SQL Case statement)

我也遇到过这个问题: 您可以将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 ...

一个复杂的sql语句(A complex sql statement)

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.clientI...

复杂删除SQL语句(Complex Delete SQL Statement)

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....

相关文章

更多

lucene4.7 过滤Filter(六)

先介绍下查询与过滤的区别和联系,其实查询(各种Query)和过滤(各种Filter)之间非常相似,可以 ...

Solr: a custom Search RequestHandler

As you know, I've been playing with Solr lately, tr ...

Custom SOLR Search Components - 2 Dev Tricks

I've been building some custom search components fo ...

solr faceted search

Faceted Search with Solr Posted byyonik Facet ...

Realtime Search: Solr vs Elasticsearch

Realtime Search: Solr vs Elasticsearch | Socialcast ...

Riak Search

Basho: Riak Search Riak Search Introduction ...

Hibernate Search(基于version3.4)--第五章Querying

Hibernate Search的第二个很重要的能力是运行Lucene queries并通过Hiber ...

ElasticSearch入门-Bulk,Search操作

其实在上一篇博客中,只要大家能看懂,就应该能够根据其代码做到举一反三了,依次类推ES的批量操作Bulk ...

table-Oceanus配置说明

作用: 描述具体的表规则 属性: name – 声明 table 名字,当命中 sql 中的 tabl ...

[How to] Make custom search with Nutch(v 1.0)?(转)

http://puretech.paawak.com/2009/04/29/how-to-make-c ...

最新问答

更多

如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)

请尝试以下方法: $messages = $user->contact_messages()->paginate(10); Try the following: $messages = $user->contact_messages()->paginate(10);

linux的常用命令干什么用的

linux和win7不一样,win7都图形界面,都是用鼠标来操作打开,解压,或者关闭。而linux是没有图形界面的,就和命令提示符一样的一个文本框,操作linux里的文件可没有鼠标给你用,打开文件夹或者解压文件之类的操作都要通过linux常用命令。

由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)

它创建了这些视图: 'auth/login.blade.php', 'auth/register.blade.php', 'auth/passwords/email.blade.php', 'auth/passwords/reset.blade.php', 'layouts/app.blade.php', 'home.blade.php' 并修改这些文件: 'Http/Controllers/HomeController.php', 'routes/web.php' 如果使用--views

如何交换返回集中的行?(How to swap rows in a return set?)

您可以使用特殊的CASE表达式进行ORDER BY如下所示: SELECT * FROM table ORDER BY CASE id WHEN 3 THEN 8 WHEN 8 THEN 3 ELSE id END You can ORDER BY using a special CASE expression like this: SELECT * FROM table ORDER BY CASE id WHEN 3 THEN 8 WHEN 8 THEN 3 ELSE id END

在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)

我建议你制作一个新的TableView Cell,在这个newTableViewCell中,加载第2节中的所有单元格,然后为newTableViewCell提供边框。 但如果您不想这样做,那么您可以使用以下代码: @property(strong,nonatomic) CAShapeLayer* borderPath; -(void)viewDidLayoutSubviews{ [_borderPath removeFromSuperlayer]; UIView *viewToGiveBord

使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)

出于一些奇怪的原因,我现在发现了一个不同的问题, Boost.Spirit SQL语法/词法分析失败 ,其中提供了一些其他解决方案来进行空格跳过。 一个更好的! 以下是根据建议重新编写的示例代码: #include #include #include #include #include #incl

Java中的不可变类(Immutable class in Java)

1.如果我只有final变量的课程? 这会让你远离但不是全部。 这些变量的类型也需要是不可变的。 考虑一下 class MyImmutableClass { // final variable, referring to a mutable type final String[] arr = { "hello" }; // ... } 这允许有人做 myImmutableObject.arr[0] = "world"; 并有效地改变你的不可变类的对象。 此外,建议禁

WordPress发布查询(WordPress post query)

如果你想要在div中包含所有帖子: post_parent) { $myposts = get_posts('numberposts=10&tag=medical&order=DESC'); echo ' '; foreach ($myposts as $post): ?>

如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)

我不确定哪个是MySQL的正确答案,因为它本身还不支持IPv6地址格式(尽管“ WL#798:MySQL IPv6支持 ”表明它将在MySQL v6.0中,当前文档不支持)。 不过,你建议的人建议去2 * BIGINT,但要确保他们是UNSIGNED。 在IPv6的/ 64地址边界处有一种自然分割(因为/ 64是最小的网格块大小),这将与其很好地对齐。 I'm not sure which is the right answer for MySQL given that it doesn't y

是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)

您可以使用Object.keys和Array#find来获取匹配value的key 。 const letters = {a:'26',b:'25',c:'24',d:'23',e:'22',f:'21',g:'20',h:'19',i:'18',j:'17',k:'16',l:'15',m:'14',n:'13',o:'12',p:'11',q:'10',r:'9',s:'8',t:'7',u:'6',v:'5',w:'4',x:'3',y:'2',z:'1'}; function sw