Quantcast
Viewing all articles
Browse latest Browse all 25064

Javascript to Filter a View based on a value in the List column

I have a sharepoint 2013 announcements list with a custom column for 'category'. This is all within a visual studio 2012 project for an app.

I would like to create a view based on a single category. There will be 5 available categories (HR, Marketing, Management, Sales, Finance), thus 5 views, one for each category.

I need some help building the JavaScript to filter the items returned by the category for example:

If category = HR

then

return all items in the view 

with the category field as 'HR'

My View definition is as follows:

<View BaseViewID="2" Name="0c73c821-447d-4f31-a53f-a0324c0325e6" 

            DisplayName="HRView" 
            Type="HTML" 
            WebPartZoneID="Main" 
            SetupPath="pages\viewpage.aspx" 
            Url="HR View.aspx">
        <RowLimit>30</RowLimit>
        
        <ViewFields>
          <FieldRef Name="LinkTitle" />
          <FieldRef Name="Image" />
          <FieldRef Name="Category1" />
          <FieldRef Name="Created" />
          <FieldRef Name="Body" />
        </ViewFields>
        
        <Query>
          <OrderBy>
            <FieldRef Name="Category1" Ascending="TRUE" />
            <FieldRef Name="Created" Ascending="FALSE" />
          </OrderBy>
          
          <GroupBy Collapse="TRUE">
            <FieldRef Name="Category1" />
          </GroupBy>
        </Query>
        
        <Toolbar Type="Standard" />
        <XslLink Default="TRUE">main.xsl</XslLink>
        <JSLink>HR.js</JSLink>
      </View>

Any help is truly appreciated.


Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>