ng-grid filter per column

12,078 views
Skip to first unread message

Pieter Herroelen

unread,
Feb 28, 2013, 6:56:41 AM2/28/13
to ang...@googlegroups.com
Hi,

Is there something foreseen in ng-grid to allow for per-column filtering? This was also asked in this thread, but not answered.

Thanks in advance,
Pieter

Tim Sweet

unread,
Mar 1, 2013, 2:19:59 AM3/1/13
to ang...@googlegroups.com
the built in search function provides a per-column filtering by specifying "Column Name : SearchVal" (and multiple column/value pairs with a semicolon delimiter). otherwise if the workbench portion of the grid source tree, you will see a header cell filtering mechanism example. 

Pieter Herroelen

unread,
Mar 1, 2013, 4:46:29 AM3/1/13
to ang...@googlegroups.com
Found it! (https://github.com/angular-ui/ng-grid/blob/master/workbench/index.html). I'll figure it out from there.

Thanks for the help,
Pieter

Brad Rice

unread,
Mar 1, 2013, 11:03:10 AM3/1/13
to ang...@googlegroups.com
I'm interested in doing this, too, Pieter. If you have a simple
example to Plunker or JS Fiddle when you discover, I would appreciate
it. I'll do the same if I figure it out.
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to angular+u...@googlegroups.com.
> To post to this group, send email to ang...@googlegroups.com.
> Visit this group at http://groups.google.com/group/angular?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Brad Rice
brad...@gmail.com
~
Do all that you can to live in peace with everyone. Rom 12:18 NLT

Brad Rice

unread,
Mar 1, 2013, 11:51:44 AM3/1/13
to ang...@googlegroups.com
I actually got it to work. This is basic.

http://plnkr.co/edit/kcgoXx

I'm still deciding if I need to have filtering work on the search with
the pull down. Right now I am setting the pulldown to undefined if you
start typing a search term and vice versa.

Pieter Herroelen

unread,
Mar 1, 2013, 11:53:49 AM3/1/13
to ang...@googlegroups.com
Hi Brad,

Have you looked at https://github.com/angular-ui/ng-grid/blob/master/workbench/index.html ? I don't know if it's hosted somewhere, I just cloned the repo and ran it locally. 

Anyway, it does what I need: an input field in the header of each column, filtering based only on the content of that column. Behind the scenes, it builds the string you would have written in the search box ("Column Name : SearchVal; Column Name2 : SearchVal2;..."), like Tim described earlier.

Best regards,
Pieter

Timothy Sweet

unread,
Mar 1, 2013, 12:07:19 PM3/1/13
to ang...@googlegroups.com
Just a heads up, you can also use regular expressions in those search
expressions. this is useful if you want to build excel style filtering
above the columns (contains, equals, starts with, ends with etc..)


On Fri, Mar 1, 2013 at 8:53 AM, Pieter Herroelen
> You received this message because you are subscribed to a topic in the
> Google Groups "AngularJS" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/angular/aC24cVln4Vw/unsubscribe?hl=en-US.
> To unsubscribe from this group and all its topics, send an email to
> angular+u...@googlegroups.com.
>
> To post to this group, send email to ang...@googlegroups.com.
> Visit this group at http://groups.google.com/group/angular?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
-Tim Sweet

Brad Rice

unread,
Mar 1, 2013, 12:14:19 PM3/1/13
to ang...@googlegroups.com
That's great. It appears the default must be contains, because if I
search using partial text, it returns something.

Brad Rice

unread,
Mar 28, 2013, 8:54:21 AM3/28/13
to ang...@googlegroups.com
Is there a way to filter on just two columns of a grid with the same text. I've figured out how to filter on a per column basis, but what I would like to do is filter on two columns with the same input.

var searchQuery = 'college:' + collegeText + ";" + 'curriculumName:' + $scope.filterText + 'department:' + $scope.filterText + ';';

Doesn't seem to work. I have to remove either department or curriculumName to get a result. Apparently, it thinks it needs to find it in both columns to return a result.

Timothy Sweet

unread,
Mar 28, 2013, 12:07:58 PM3/28/13
to ang...@googlegroups.com
You're forgetting a ; after the curriculum query before department.

Brad Rice

unread,
Mar 28, 2013, 3:24:48 PM3/28/13
to ang...@googlegroups.com
Unfortunately that didn't work I console.logged it to the screen:

curriculumName:3150;department:3150;

It appears it needs to find it in both columns rather than just one to
give me a return. If I type in Chemistry, I get something back because
it is in both columns, but if I type something unique in to a column I
get nothing in return.
Brad Rice
brad...@gmail.com
~
“So many books, so little time.” - Frank Zappa

Timothy Sweet

unread,
Mar 28, 2013, 3:38:10 PM3/28/13
to ang...@googlegroups.com
you can also use regular expressions in the queries

Victor Hooi

unread,
Mar 28, 2013, 7:32:35 PM3/28/13
to ang...@googlegroups.com
Hi,

Did the per-column filtering example disappear recently?

I just checked-out from Github, and opened up workbench/index.html, and there isn't any per-column filtering? (Also tried serving up through local webserver, in case that was it - also no go).

Cheers,
Victor

Pieter Herroelen

unread,
Mar 29, 2013, 6:32:03 AM3/29/13
to ang...@googlegroups.com
Hi,


Best regards,
Pieter

CG

unread,
May 8, 2013, 9:23:15 PM5/8/13
to ang...@googlegroups.com
I've been having a lot of trouble with this... I found what I think is the relevant code chunk in workbench/index5, but that demo is totally broken for me so I can't figure out where the filtering is actually occurring.

I'm trying to get filter-by-column working (just for the first column, at the moment) and am clearly doing something very wrong. Can anyone help? http://plnkr.co/edit/70MMFWS6YJSyi4xHQroh?p=preview

Thank you SO much!!

Brad Rice

unread,
May 8, 2013, 9:50:16 PM5/8/13
to ang...@googlegroups.com
Try this on line 76

$scope.filterText = "campaign: " + searchText + "; ";


--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/aC24cVln4Vw/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Brad Rice
brad...@gmail.com
~
“God has promised pardon to your conversion; He has not promised a tomorrow to your delay.” - Augustine

CG

unread,
May 8, 2013, 10:22:08 PM5/8/13
to ang...@googlegroups.com
Well that fixes the errors (thanks!!) but it searches both columns. I type in "print" and instead of getting no results, like i should were I only searching the "campaigns" column, I get all the channel = print results. Any ideas?

Brad Rice

unread,
May 9, 2013, 9:24:54 AM5/9/13
to ang...@googlegroups.com
I've banged around on it and can't figure it out. I wonder if something has changed with column search in the latest version because it isn't working for me.

CG

unread,
May 9, 2013, 1:38:51 PM5/9/13
to ang...@googlegroups.com
Thank you for trying! For the time being, I've opened an issue, hopefully I'll figure it out. I highly suspect something is wrong, given that most of the 9 demos packaged with ng-grid don't even render for me.

Brad Rice

unread,
May 9, 2013, 2:11:13 PM5/9/13
to ang...@googlegroups.com
This is very bizarre to me, but I found if I take filterOptions out of the gridOptions and set it separately on the scope it works. Here is my fork:



On Thu, May 9, 2013 at 1:38 PM, CG <cge...@gmail.com> wrote:
Thank you for trying! For the time being, I've opened an issue, hopefully I'll figure it out. I highly suspect something is wrong, given that most of the 9 demos packaged with ng-grid don't even render for me.

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/aC24cVln4Vw/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

CG

unread,
May 9, 2013, 2:51:51 PM5/9/13
to ang...@googlegroups.com
Brad, thanks! I've actually gotten some more info by posting an issue on ng-grid - explaining the difference between $scope.gridOptions.filterOptions.filterText and $scope.filterText. I've still got a long way to go, but this is a start!

code solver

unread,
Sep 10, 2013, 8:55:12 AM9/10/13
to ang...@googlegroups.com
to hide/show specific columns in ng grid you can use columnsDef property of ng grid

Reply all
Reply to author
Forward
0 new messages