Forum
Topic RSS
13:06
10/03/2010
OfflineHi,
I found out how to do this with columns containing values in a selected list (by introducing a value " : " in the list), but I still can't figure out how to do this for editable fields. I've tried to do a search on all elements that contains a caracter (#column,#contain,%), and then to display all elements that don't match with this pattern, but I get all rows...
Do you have any idea on how to perform this kind of search? Is it a bug in my implementation of the grid, or a grid problem?
Thanks
21:22
Moderators
30/10/2007
OfflineHello,
Do you perform the search on the server?
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
17:45
10/03/2010
OfflineHi,
Thanks for your reply.
Actually, I don't have any more this problem for varchar. This is how I fixed it for varchar columns:
- modify the database columns' default to '' instead of NULL (doesn't work on text type)
alter table <table> alter column <column> set Default ''
- modify all values of all columns that contain a NULL value, and set it to the new default's one
update <table> set <field> = '' where <field> IS NULL
- insert a space in the filter's entry, and press enter to get the results.
Now, the filter is ok for selectable values (I added a ; :Nothing in the values list), for text and for varchar values. I still can't perform this kind of search on dates (all cells that don't contain dates).
ps1 : I should precise that I'm talking about the inline filter, not the search box function.
ps2 : Yes, I perform the search on server's side
Here is the code that perform the search :
if($searchOn=='true')
{
if(isset($_POST['filters'])&&$_POST['filters']!="")
{
$sarr = json_decode(Strip($_POST['filters']), true);
foreach($sarr['rules'] as $table)
{
$wh.=$wh==""?" WHERE ":" AND ";
switch($table['op'])
{ case 'bn':
$wh .= $table['field']." NOT LIKE '".$table['data']."%'";
break;
case 'eq':
$wh .= $table['field']." = '".$table['data']."'";
break;
case 'bw':
$wh .= $table['field']." LIKE '".$table['data']."%'";
break;
case 'ne':
$wh .= $table['field']." <> '".$table['data']."'";
break;
case 'ew':
$wh .= $table['field']." LIKE '%".$table['data']."'";
break;
case 'en':
$wh .= $table['field']." NOT LIKE '%".$table['data']."'";
break;
case 'cn':
$wh .= $table['field']." LIKE '%".$table['data']."%'";
break;
case 'nc':
$wh .= $table['field']." NOT LIKE '%".$table['data']."%'";
break;
case 'lt':
$wh .= $table['field']." < '".$table['data']."'";
break;
case 'gt':
$wh .= $table['field']." > '".$table['data']."'";
break;
case 'le':
$wh .= $table['field']." <= '".$table['data']."'";
break;
case 'ge':
$wh .= $table['field']." >= '".$table['data']."'";
break;
case 'in':
$wh .= $table['field']." IN (".$table['data'].")";
break;
case 'ni':
$wh .= $table['field']." NOT IN (".$table['data'].")";
break;
default:
break;
}
}
}
foreach($_POST as $champ => $valeur)
{
if(in_array($champ, $liste_champs))
{
$wh.=$wh==""?" WHERE ":" AND ";
if(strstr($valeur,"%"))
{
$wh .= $champ." LIKE '".$valeur."'";
}
else
{
$wh .= $champ." = '".$valeur."'";
}
}
}
Most Users Ever Online: 994
Currently Online:
38 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66
Log In
Home