English 中文(简体)
缩略语
原标题:datatables checkbox to toggle WHERE clause

因此,我目前以冷藏和一切照样把我的数据简单地放在一起。 我的“结构”一栏是现状。 目前,我正在恢复WHERE的所有成果! 完成

This has worked fine for now, but what I would really like to do is place a checkbox on the page just above the datatable and when checked it would show all records including those that are completed.

问题在于,我能否在检查箱上进行某种敲响,以便动态地排除条款的哪里,或者我是否向数据表提供所有记录,并过滤它? 我对此感到担忧的唯一情况是,当数据库得到大量使用时,将所有记录退回,可能还需要90%的时间才能被过滤。

无论是哪种方式,法典都非常有用!

增 编

最佳回答

RESOLVED

iKnowKungFoo was right. Since I am using pagination in datatables, the query is limited to those rows anyway, eliminating the worry for the large return result. I implemented the following code to put a jqueryui toggle button.

j)

$( #completed_button ).bind( change , function(){
   if($(this).is( :checked )){
      $(this).button( option ,  label ,  Hide Completed );
      oTable.fnFilter( Completed ,6,false);
   } else {
      $(this).button( option ,  label ,  Show Completed );
      oTable.fnFilter(  ,6,false);
   }
});

html

<input class="toggle-button" id="completed_button" type="checkbox"  /><label for="completed_button">Show Completed</label>

SQL

WHERE 1 =1 
<cfif trim(url.sSearch_6) NEQ "Completed">
   AND TS.tickets_status_id != <cfqueryparam cfsqltype="cf_sql_integer" value="13" />
</cfif>
问题回答

我这样说,这种方法取决于你预测的数据数量。 如果检查箱只过滤或包含少量记录,将记录列入数据回报,并过滤用户。 如果该检查箱将对结果套产生重大影响,在检查箱发生变化时重新使用数据电话,在服务器上进行过滤可能是一个更好的办法。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签