Comments (15)
I accidentally duplicated this bug report, but ran into a separate issue. My
duplicate report with separate issue is Issue 26. I do not see how your or my
solution yields a functioning filter as long as there are more than one number
range. Were you able to resolve this?
Original comment by [email protected]
on 1 Aug 2011 at 1:04
from jquery-datatables-column-filter.
I use only number range + date range, try this:
@@ -304,8 +305,8 @@
for (j = 0; j < aiCustomSearch_Indexes.length; j++) {
var index = aiCustomSearch_Indexes[j];
- var fnSearch_ = function () {
- return $("#range_from_" + index).val() +
properties.sRangeSeparator + $("#range_to_" + index).val()
+ var fnSearch_ = function (fieldIndex) {
+ return $("#" + oTable.attr("id") + "_range_from_" +
fieldIndex).val() + properties.sRangeSeparator + $("#" + oTable.attr("id") +
"_range_to_" + fieldIndex).val();
}
afnSearch_.push(fnSearch_);
}
@@ -321,7 +322,7 @@
for (k = 0; k < aoData.length; k++) {
if (aoData[k].name == "sSearch_" + index)
- aoData[k].value = afnSearch_[j]();
+ aoData[k].value = afnSearch_[j](index);
}
}
aoData.push({ "name": "sRangeSeparator", "value": properties.sRangeSeparator });
Original comment by [email protected]
on 1 Aug 2011 at 3:57
from jquery-datatables-column-filter.
Thank you! That is _infinitely_ better than the eval() solution I came up with!
Original comment by [email protected]
on 1 Aug 2011 at 5:32
from jquery-datatables-column-filter.
i am sorry to say but this did not fix my issue with server side range
filtering. I have:
for (j = 0; j < aiCustomSearch_Indexes.length; j++) {
var index = aiCustomSearch_Indexes[j];
var fnSearch_ = function (fieldIndex) {
return $("#" + oTable.attr("id") + "_range_from_" + fieldIndex).val() + properties.sRangeSeparator + $("#" + oTable.attr("id") + "_range_to_" + fieldIndex).val();
}
afnSearch_.push(fnSearch_);
}
and
for (k = 0; k < aoData.length; k++) {
if (aoData[k].name == "sSearch_" + index) {
oData[k].value = afnSearch_[j](index);
}
}
did i forget something? The database field i am trying to sort is a float,
does that matter?
Do i need to define the min and max in the html?
Original comment by [email protected]
on 12 Aug 2011 at 1:06
from jquery-datatables-column-filter.
What you get from this script on the server side?
Original comment by [email protected]
on 12 Aug 2011 at 2:52
from jquery-datatables-column-filter.
sRangeSeparator ~
sSearch
sSearch_0
sSearch_1
sSearch_2
sSearch_3 undefined~undefined
sSearch_4
sSortDir_0 asc
is what firebug shows as parameters sent to the server when i begin typing
something
Original comment by [email protected]
on 12 Aug 2011 at 3:57
from jquery-datatables-column-filter.
sorry, i looked at my code some more and found a mistake.
The parameters are now being sent correctly, but i am still not getting any
records when i type anything i get no matching records.
sRangeSeparator ~
sSearch
sSearch_0
sSearch_1
sSearch_2
sSearch_3 1.1~9.9
sSearch_4
sSortDir_0 asc
these are the parameters now being sent.
Original comment by [email protected]
on 12 Aug 2011 at 4:28
from jquery-datatables-column-filter.
You can modify your server-side scripts.
jQuery.DataTables server-side example
(http://www.datatables.net/release-datatables/examples/server_side/server_side.h
tml) don't work with ranges.
For example, lines from 88 to 106:
https://github.com/riuson/eaaphp2/blob/313491b1bb9a8d997dc586b581e58eda8b6b03b1/
classes/datatables_common.php
Original comment by [email protected]
on 12 Aug 2011 at 5:50
from jquery-datatables-column-filter.
Thank you for your suggestion. I see exactly what you are talking about.
Do you have a simple example of where to put that in my server side script to
get range filtering to work correctly? I tried to follow along with your
project on git hub, but it is very sophisticated.
Original comment by [email protected]
on 12 Aug 2011 at 3:07
from jquery-datatables-column-filter.
Vanilla server-side script from
http://www.datatables.net/release-datatables/examples/server_side/server_side.ht
ml
Modified with this:
--- vanilla.php 2011-08-12 21:18:34 +0500
+++ modified.php 2011-08-12 21:29:28 +0500
@@ -107,7 +107,24 @@
{
$sWhere .= " AND ";
}
- $sWhere .= $aColumns[$i]." LIKE
'%".mysql_real_escape_string($_GET['sSearch_'.$i])."%' ";
+ $columnFilterValue =
$this->registry['db']->escape($_POST['sSearch_' . $i]);
+ // check for values range
+ $rangeSeparator = "~";
+ if (!empty($rangeSeparator) &&
strstr($columnFilterValue, $rangeSeparator)) {
+ // get min and max
+ preg_match("/(.*)\~(.*)/", $columnFilterValue,
$columnFilterRangeMatches);
+ // get filter
+ if (empty($columnFilterRangeMatches[1]) &&
empty($columnFilterRangeMatches[2]))
+ $sWhere .= " 0 = 0 ";
+ else if (!empty($columnFilterRangeMatches[1])
&& !empty($columnFilterRangeMatches[2]))
+ $sWhere .= $aColumns[$i] . " BETWEEN '"
. $columnFilterRangeMatches[1] . "' and '" . $columnFilterRangeMatches[2] . "'
";
+ else if (empty($columnFilterRangeMatches[1]) &&
!empty($columnFilterRangeMatches[2]))
+ $sWhere .= $aColumns[$i] . " < '" .
$columnFilterRangeMatches[2] . "' ";
+ else if (!empty($columnFilterRangeMatches[1])
&& empty($columnFilterRangeMatches[2]))
+ $sWhere .= $aColumns[$i] . " > '" .
$columnFilterRangeMatches[1] . "' ";
+ } else {
+ $sWhere .= $aColumns[$i] . " LIKE '%" .
$columnFilterValue . "%' ";
+ }
}
}
Original comment by [email protected]
on 12 Aug 2011 at 3:31
Attachments:
from jquery-datatables-column-filter.
Thank you so much for this explanation. I had the error:
Using $this when not in object context in
/examples/server_side/scripts/modified.php on line 109
but i fixed it with the following line and everything works! Thank you for
your help!
}
$sWhere .= $aColumns[$i]." LIKE '%".mysql_real_escape_string($_GET['sSearch_'.$i])."%' ";
- $columnFilterValue =
$this->registry['db']->escape($_POST['sSearch_' . $i]);
+ $columnFilterValue = mysql_real_escape_string($_GET['sSearch_' . $i]);
// check for values range
$rangeSeparator = "~";
Original comment by [email protected]
on 12 Aug 2011 at 5:14
from jquery-datatables-column-filter.
Hi,
Could you please try it again with verison 1.2.3?
Thanks,
Jovan
Original comment by [email protected]
on 24 Sep 2011 at 11:28
- Changed state: Started
from jquery-datatables-column-filter.
Please reopen this issue if it happens again with the latest version of code.
Thanks,
Jovan
Original comment by [email protected]
on 25 Sep 2011 at 7:00
- Changed title: undefined value of ranges in the server side mode
- Changed state: Fixed
- Added labels: Priority-High
- Removed labels: Priority-Medium
from jquery-datatables-column-filter.
Do we still need to modify the server processing script from datatables?
I'm still not getting it to work, although it does go a lot further than it did
toward working.
Original comment by [email protected]
on 26 Sep 2011 at 4:37
from jquery-datatables-column-filter.
I used the modified server processing PHP along with the one line change on
comment 11 and it is now working.
Original comment by [email protected]
on 26 Sep 2011 at 5:08
from jquery-datatables-column-filter.
Related Issues (20)
- Change sAjaxSource
- Datatables show/hide columns disturbs column filtering
- How to style columnFiltering
- apply filters to several tables
- CSS bootstrap and number_range_filter HOT 1
- Server side Processing is not working HOT 1
- ColumnFilter doesn't work with columns with hyperlink HOT 1
- How to Filter Exact match value in cloumnFilter.js?
- how to search when i were select a comboxlist,then the second comboxlist value show the relationship of the first comboxlist
- IE10+ touch events not supported
- Default Filtervalue not send when bServerSide processing
- select with checkboxes
- Datatable select filters with checkboxes
- how to clear multi colum filter in datatable
- Unable to sort when using the plugin
- type:slect not working
- Checkbox not able to filter that contain symbol
- text-range filtering
- Issue on responsive jquery datatables + external form column filter
- When date fields are null, no data is diplayed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-datatables-column-filter.