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

刷新后数据表搜索为空,但过滤器处于活动状态(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

相关问答

更多
  • 通过简单地将序列本身包装在一个数组中,可以将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) ...
  • 您正在寻找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 ...
  • 要获得您的查询,您应该可以执行以下操作: $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 = ...
  • 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语句。 如果你需要,请告诉我,因为我认为这不是问题。 它可能没有那么高效,但我认为这并不重要,但 ...
  • 我认为你走在正确的轨道上。 我会使用表名,如: 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 ...
  • 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 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 ...

相关文章

更多

最新问答

更多
  • Runnable上的NetworkOnMainThreadException(NetworkOnMainThreadException on Runnable)
  • C ++ 11 + SDL2 + Windows:多线程程序在任何输入事件后挂起(C++11 + SDL2 + Windows: Multithreaded program hangs after any input event)
  • AccessViolationException未处理[VB.Net] [Emgucv](AccessViolationException was unhandled [VB.Net] [Emgucv])
  • 计算时间和日期差异(Calculating Time and Date difference)
  • 以编程方式标签NSMutableAttributedString swift 4(Label NSMutableAttributedString programmatically swift 4)
  • C#对象和代码示例(C# objects and code examples)
  • 在python中是否有数学nCr函数?(Is there a math nCr function in python? [duplicate])
  • 检索R中列的最大值和第二个最大值的行名(Retrieve row names of maximum and second maximum values of a column in R)
  • 给定md5哈希时如何查找特定文件(How to find specific file when given md5 Hash)
  • Python字典因某些原因引发KeyError(Python Dictionary Throwing KeyError for Some Reason)
  • 如何让Joomla停止打开新标签中的每个链接?(How do I get Joomla to stop opening every link in a new tab?)
  • DNS服务器上的NS记录不匹配(Mismatched NS records at DNS server)
  • Python屏幕捕获错误(Python screen capture error)
  • 如何在帧集上放置div叠加?(How to put a div overlay over framesets?)
  • 页面刷新后是否可以保留表单(html)内容数据?(Is it possible to retain the form(html) content data after page refreshed?)
  • 使用iTeardownMyAppFrame和iStartMyAppInAFrame在OPA5测试中重新启动应用程序超时(Restart app within OPA5 test using iTeardownMyAppFrame and iStartMyAppInAFrame timed out)
  • 自动拆分文本内容到列(Automatically splitting text content into even columns)
  • 在r中的循环中将模型名称分配给gbm.step(assigning model names to gbm.step in loop in r)
  • 昆明哪里有电脑等级考试二级C培训?
  • C ++模板实例化,究竟是什么意思?(C++ template instantiation, what exactly does it mean?)
  • 帮助渲染来自fields_for的部分内容(Help to render a partial from fields_for)
  • 将url.action作为json对象返回mvc(return url.action as json object mvc)
  • 使用.BAT中的.application文件类型运行ac#Console App(Run a c# Console App with .application file type from a .BAT)
  • 将bindingRedirect添加到.Net标准库(Adding a bindingRedirect to a .Net Standard library)
  • Laravel版本升级会影响您的控制器吗?(Laravel version upgrade affects your controller?)
  • imaplib.error:命令SEARCH在状态AUTH中非法,只允许在SELECTED状态(imaplib.error: command SEARCH illegal in state AUTH, only allowed in states SELECTED)
  • 如何在eclipse debug impala前端
  • 如何通过Ajax API处理多个请求?(How to handle multiple requests through an Ajax API? [closed])
  • 使用Datetime索引来分析数据框数据(Using Datetime indexing to analyse dataframe data)
  • JS 实现一个菜单效果