Forum

July 12th, 2025
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Filter on empty cells
10/03/2010
18:48
Avatar
ephilippon
Member
Members
Forum Posts: 3
Member Since:
10/03/2010
sp_UserOfflineSmall Offline

Hi all, congrats for this wonderful plugin!

As a new jqGrid user, I wonder if it could be possible to filter a column in order to show only rows that have an empty cell. For instance, it could be really helpful to see rows where there's a missing data.

Thanks a lot.

Eric

12/03/2010
13:06
Avatar
ephilippon
Member
Members
Forum Posts: 3
Member Since:
10/03/2010
sp_UserOfflineSmall Offline

Hi,

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

15/03/2010
21:22
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

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/03/2010
17:45
Avatar
ephilippon
Member
Members
Forum Posts: 3
Member Since:
10/03/2010
sp_UserOfflineSmall Offline

Hi,

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."'";

}

}

}

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information