Filtering a single column

May 16, 2011 at 7:44 PM

Can I show the filter field just for a specific column?

 

Thx

May 16, 2011 at 7:53 PM
What are you asking about? You'll have to give more detail.
M.
May 16, 2011 at 7:55 PM

Sure.

The JavaScript puts a search field above every column in the view. I want it above just one specific column.

Thx.

May 16, 2011 at 8:03 PM

You'll need to change the selector in this line so that it only selects the column(s) where you want the filtering to be available:

$(this).children("th,td").each(function()

What this currently does is select all th or td cells within the header row.

For instance, if you wanted to select the fourth th, you'd do:

$(this).children("th:eq(4)").each(function()

M.

May 16, 2011 at 8:43 PM

Thx sympmarc.

Unfortunately, it didn' worked. I got a view with 4 columns (Attachments, TextField1, TextField2 and PictureField). If I try to use "th:eq(2)", it shows a search field in the left and the filter gives no results (please see image).


 

It happens athe same way with "th:eq(3)" and "th:eq(4)". If I try "th:eq(1)", it gives me no search field.

Any clues?

 

Thx

May 16, 2011 at 8:48 PM
Edited May 16, 2011 at 8:54 PM

Yeah, looking at the code some more, it's a bit more complicated. Which column do you want to have the filtering on?

  $(this).children("th,td").each(function(ii)
  {
   if($(this).hasClass("ms-vh-icon") || ii != 2)

If you alter the code as above, it ought to do what you want. I just tested this, and it works in my test view. You'll want to change the 2 to whatever zero offset column number you need.

M.

May 16, 2011 at 8:53 PM

"Ramal", the 3rd one (after Attachments and "Título").

 

Thx.

May 16, 2011 at 8:54 PM

See my edit above.

M.

May 16, 2011 at 9:07 PM

It worked.

I appreciate your attention and patience. It helped me a lot!

 

Thx

May 16, 2011 at 9:08 PM

Sure thing!

M.

Sep 29, 2011 at 12:44 AM

I would like the reverse of this. How do I exclude one or several filter fileds from columns?

Thanks 

Sep 29, 2011 at 5:40 AM

Hi RALUT.

I would try

 

$(this).children("th,td").each(function(ii)
  {
   if($(this).hasClass("ms-vh-icon") || ii == 2)

 

instead of

 

$(this).children("th,td").each(function(ii)
  {
   if($(this).hasClass("ms-vh-icon") || ii != 2)

 

Remember that the number 2 refers to the column you want to hide the search field.

Sep 29, 2011 at 2:34 PM

Thanks!!! That worked. I thought I tried that but...

Multiple ORs work as well:

  $(this).children("th,td").each(function(ii)
  {
   if($(this).hasClass("ms-vh-icon") || ii==1 || ii==3)