I am using Datatables Editor to populate a grid and want to filter it using different "WHERE" clauses. My code is as follows:
我使用Datatables Editor来填充网格,并希望使用不同的“WHERE”子句对其进行过滤。我的代码如下:
jQuery
// Valid Customer Accounts
$('#lnkValidCustomers').click(function () {
// Redraw Grid
customersTable.ajax.url('dataGridQuery.php?varCurrentCustomers=y&varInvalidCustomers=n').load();
});
// Invalid Customer Accounts
$('#lnkInvalidCustomers').click(function () {
// Redraw Grid
customersTable.ajax.url('dataGridQuery.php?varCurrentCustomers=n&varInvalidCustomers=y').load();
});
//All Customer Accounts
$('#lnkShowAllCustomers').click(function () {
// Redraw Grid
customersTable.ajax.url('dataGridQuery.php?varCurrentCustomers=y&varInvalidCustomers=y').load();
});
PHP
// Database Fields
$editor = Editor::inst( $db, 'tblCustomers', 'customerID' )
->fields(
Field::inst( 'customerID' ),
Field::inst( 'customerName' ),
Field::inst( 'customerNotValidDate' )
);
// Where Clauses
if (isset($_GET['varCurrentCustomers']) && $_GET['varCurrentCustomers']=='y' && isset($_GET['varInvalidCustomers']) && $_GET['varInvalidCustomers']=='n') { // All Valid Customers.
// Apply Filter
$editor
->where('tblCustomers.customerNotValidDate', '', '=' );
} else if (isset($_GET['varCurrentCustomers']) && $_GET['varCurrentCustomers']=='n' && isset($_GET['varInvalidCustomers']) && $_GET['varInvalidCustomers']=='y') { // All Invalid Customers.
// Apply Filter
$editor
->where( 'tblCustomers.customerNotValidDate', '', '!=' );
} else if (isset($_GET['varCurrentCustomers']) && $_GET['varCurrentCustomers']=='y' && isset($_GET['varInvalidCustomers']) && $_GET['varInvalidCustomers']=='y') { // All Customers.
// Apply Filter
// No Filter
}
// Process Json
$editor
->process( $_POST )
->json();
The problem I have is that the $_GET variables repeat and therefore not applying the desired WHERE clause. Below is a console example of the parameter results:
我遇到的问题是$ _GET变量重复,因此不应用所需的WHERE子句。下面是参数结果的控制台示例:
Console
gridNumber 3
varCurrentCustomers y
varCurrentCustomers n
varInvalidCustomers y
varInvalidCustomers n
I think the problem involves attempting to use the PHP $_GET parameters as jQuery variables; please let me know. Any help in this regard is appreciated. I am a self taught amateur web developer. :)
我认为问题涉及尝试将PHP $ _GET参数用作jQuery变量;请告诉我。在这方面的任何帮助表示赞赏。我是一名自学成才的业余网站开发人员。 :)
1 个解决方案
#1
0
try
$editor
->process($_GET)
->json();
is missing the values in "where"
缺少“where”中的值
#1
0
try
$editor
->process($_GET)
->json();
is missing the values in "where"
缺少“where”中的值