Skip to content
GravityKit
Buy
Sign in
0 items
  • Plugins

    GravityKit All Access

    Our complete Kit of essential tools for extending and enhancing Gravity Forms—everything you need to build powerful web apps and workflows.

    Learn more
    • GravityView Pro

      GravityView Pro

      Bestseller

      Get Live Filters, Maps, DataTables, the Advanced Elementor Widget and every other Pro feature to build the app your process needs.

    • GravityView

      GravityView

      Trending

      Display Gravity Forms entries on the frontend of your site and build powerful web applications.

    • GravityImport

      GravityImport

      Trending

      Import entries from CSV files into Gravity Forms to transfer data, create new forms, or update existing entries.

    • GravityEdit

      GravityEdit

      Quickly edit Gravity Forms entries inline to save time, reduce clicks, and streamline your workflow.

    • GravityCharts

      GravityCharts

      Trending

      Turn Gravity Forms entries into interactive charts and graphs.

    • GravityActions

      GravityActions

      Update multiple Gravity Forms entries at once, send bulk emails, and streamline your workflow.

    • GravityCalendar

      GravityCalendar

      Turn Gravity Forms entries into dynamic calendars to showcase events, schedules, appointments, and more.

    • GravityExport

      GravityExport

      Export Gravity Forms entries to Excel, CSV, PDF, or Google Sheets, then share them with secure links or deliver them to cloud storage on a schedule.

    • GravityMath

      GravityMath

      Perform advanced calculations on Gravity Forms entries to display totals, averages, or build custom calculators.

    • GravityRevisions

      GravityRevisions

      Track, compare, and restore changes made to Gravity Forms forms and entries with a full version history.

    • GravityMigrate

      GravityMigrate

      Migrate all Gravity Forms data between sites, including forms, entries, settings, Views, feeds, and file uploads, and import forms from other form plugins.

    • GravityBoard

      GravityBoard

      Manage projects with collaborative project management. Coordinate with your team and streamline your workflows.

    • GravitySearch

      GravitySearch

      Search Gravity Forms entries across every form from one screen.

  • Ideal For

    • Nonprofits
    • Web Agencies
    • Education
    • Developers
    • Small Businesses
    • Startups
    Explore All Use Cases

    Case studies

    • Be There Local
    • Killer Shorts
    • West Fork Schools
    • Princeton University
    • BrightLeaf Giving
    • Jacksonville Port Authority
    • National Severe Storms Lab
    • Leadpal
    View All Case Studies
  • Resources

    • Blog
    • Case studies
    • Newsletter
    • GravityKit vs competitors
    • Live Demos
    • Documentation
    • Developer docs
    • GravityKit Academy

    Ultimate guides

    • How to use Gravity Forms
    • Editing Gravity Forms entries
    • Importing Gravity Forms entries
    • Exporting Gravity Forms entries
    • Displaying Gravity Forms entries
    • Gravity Forms conditional logic
    • Gravity Forms calculations
    View More Articles
  • Support
  • Pricing
  • Plugins

    • GravityView Pro

      GravityView Pro

      Bestseller

      Get Live Filters, Maps, DataTables, the Advanced Elementor Widget and every other Pro feature to build the app your process needs.

    • GravityView

      GravityView

      Trending

      Display Gravity Forms entries on the frontend of your site and build powerful web applications.

    • GravityImport

      GravityImport

      Trending

      Import entries from CSV files into Gravity Forms to transfer data, create new forms, or update existing entries.

    • GravityEdit

      GravityEdit

      Quickly edit Gravity Forms entries inline to save time, reduce clicks, and streamline your workflow.

    • GravityCharts

      GravityCharts

      Trending

      Turn Gravity Forms entries into interactive charts and graphs.

    • GravityActions

      GravityActions

      Update multiple Gravity Forms entries at once, send bulk emails, and streamline your workflow.

    • GravityCalendar

      GravityCalendar

      Turn Gravity Forms entries into dynamic calendars to showcase events, schedules, appointments, and more.

    • GravityExport

      GravityExport

      Export Gravity Forms entries to Excel, CSV, PDF, or Google Sheets, then share them with secure links or deliver them to cloud storage on a schedule.

    • GravityMath

      GravityMath

      Perform advanced calculations on Gravity Forms entries to display totals, averages, or build custom calculators.

    • GravityRevisions

      GravityRevisions

      Track, compare, and restore changes made to Gravity Forms forms and entries with a full version history.

    • GravityMigrate

      GravityMigrate

      Migrate all Gravity Forms data between sites, including forms, entries, settings, Views, feeds, and file uploads, and import forms from other form plugins.

    • GravityBoard

      GravityBoard

      Manage projects with collaborative project management. Coordinate with your team and streamline your workflows.

    • GravitySearch

      GravitySearch

      Search Gravity Forms entries across every form from one screen.

    View All Products

    GravityKit All Access

    Our complete Kit of essential tools for extending and enhancing Gravity Forms—everything you need to build powerful web apps and workflows.

    Learn more
  • Ideal For

    • Nonprofits
    • Web Agencies
    • Education
    • Developers
    • Small Businesses
    • Startups
    Explore All Use Cases

    Case studies

    • Be There Local
    • Killer Shorts
    • West Fork Schools
    • Princeton University
    • BrightLeaf Giving
    • Jacksonville Port Authority
    • National Severe Storms Lab
    • Leadpal
    View All Case Studies

    How to build...

    • Client Portal
    • AI-Built Directory
    • Conference Website
    • WordPress CRM
    • Admin Dashboard
    • Inventory Management
    • Vendor Portal
    • Document Library
    View All Guides
  • Resources

    • Blog
    • Case studies
    • Newsletter
    • GravityKit vs competitors
    • Live Demos
    • Documentation
    • Developer docs
    • GravityKit Academy

    ultimate guides

    • How to use Gravity Forms
    • Editing Gravity Forms entries
    • Importing Gravity Forms entries
    • Exporting Gravity Forms entries
    • Displaying Gravity Forms entries
    • Gravity Forms conditional logic
    • Gravity Forms calculations
    View More Articles
  • Support
  • Pricing
0 items

Search

Results appear automatically as you type.
Loading results…

results found matching

    Sign in
    Buy

    Docs

    • Docs Home

    Gravity Forms Add-Ons

    • GravityView
    • GravityActions
    • GravityBoard
    • GravityCalendar
    • GravityCharts
    • GravityEdit
    • GravityExport
    • GravityImport
    • GravityMath
    • GravityRevisions
    • GravitySearch
    • GF Widget for Elementor
    • GF Dynamic Lookup
    • GF Entry Tags
    • GF Event Field
    • GravityExport Lite
    • GF Zero Spam
    • GravityMigrate

    GravityView

    • Getting Started
    • View Setup
    • FAQ
    • Pre-Sale
    • Advanced
    • Common Problems
    • Customizing Your Views
    • Edit Entry
    • Entry Approval
    • Filter and Sort Results
    • Gravity Forms
    • Merge Tags
    • Roles and Capabilities
    • Search
    • Shortcodes
    • View Settings
    • WordPress Posts

    General Help

    • Account, Invoices, and Billing
    • License Related
    • Plugins and Settings
    • Agency accounts
    • Contact
    • Docs Home
    • Gravity Forms Add-Ons

      • GravityView
      • GravityActions
      • GravityBoard
      • GravityCalendar
      • GravityCharts
      • GravityEdit
      • GravityExport
      • GravityImport
      • GravityMath
      • GravityRevisions
      • GravitySearch
      • GF Widget for Elementor
      • GF Dynamic Lookup
      • GF Entry Tags
      • GF Event Field
      • GravityExport Lite
      • GF Zero Spam
      • GravityMigrate
    • GravityView

      • Getting Started
      • View Setup
      • FAQ
      • Pre-Sale
      • Advanced
      • Common Problems
      • Customizing Your Views
      • Edit Entry
      • Entry Approval
      • Filter and Sort Results
      • Gravity Forms
      • Merge Tags
      • Roles and Capabilities
      • Search
      • Shortcodes
      • View Settings
      • WordPress Posts
    • General Help

      • Account, Invoices, and Billing
      • License Related
      • Plugins and Settings
      • Agency accounts
    • Contact

    GravityView Pro

      • Selling listings and featured spots that end on their own
      • Showing entries added since a user’s last login
      • Showing only paid entries: filtering a View by payment status
      • (Advanced) What changed from 1.x to 2.0?
      • Advanced Filter shows no entries, or fewer than expected
      • Field Conditional Logic
      • Field Conditional Logic doesn’t hide entries
      • Filtering a View using the Assignee field from Gravity Flow
      • Filtering by entry approval status
      • Filtering by the week of the year
      • Getting started with Advanced Filtering
      • How to show only entries created by the currently logged-in user
      • How to show only entries from the current day, week, month, or year
      • I can’t type a relative date in an Advanced Filter condition
      • Showing only entries created by users with a certain role
      • The :disabled_admin merge tag modifier
      • Using Advanced Filtering with Multiple Forms
      • Why can’t I see the Fields dropdown?
      • Change the search parameter from “letter” to something else
      • Configuring the A-Z Filters Widget
      • The “Use this field to filter entries” setting
      • Choosing which fields show in the dashboard and on your website
      • Dashboard Views: Display the View title
      • Dashboard Views: How to modify the menu icon
      • Dashboard Views: The included CSS Frameworks
      • Getting started with Dashboard Views
      • Controlling column widths and pinning columns in DataTables
      • Fixing a DataTables View that shows “This table could not load” or stays on “Loading data…”
      • Adding a company logo to DataTables PDF exports
      • Buttons (DataTables Setting)
      • Changing the style of the export buttons in DataTables
      • Customizing DataTables options in GravityView
      • DataTables Data Processing Mode (AJAX or Preloaded)
      • DataTables Field Filters
      • DataTables: is it possible to exclude fields from printing?
      • Displaying a DataTables View from a theme template
      • Enable Auto-Update (DataTables Setting)
      • Getting started with the DataTables Layout
      • Grouping rows by common field values
      • How a DataTables View sorts its entries
      • How to change the separator in DataTables CSV exports
      • How to customize the “Loading data” text
      • How to customize the Excel export file name
      • How to disable the “Loading data” message
      • How to translate the DataTables script
      • Is there a way to style the PDF on DataTables?
      • Making links clickable in DataTables PDF exports
      • Multi-sorting columns in DataTables
      • My column widths aren’t being respected when using Responsive Tables
      • My DataTables View is not sorting properly
      • Removing HTML tags from DataTables Excel exports
      • Removing the striped background from DataTables
      • Responsive (DataTables Setting)
      • Scroller (DataTables Setting)
      • Showing images and URLs in DataTables printouts
      • Showing images in DataTables PDF exports
      • Showing URLs in DataTables Excel exports
      • The Save Table State setting in DataTables
      • The text inside a column is going out of the screen
      • DIY Layout: Remove the “Go back” link
      • DIY Version 2.2 changes to HTML output
      • Getting started with the DIY Layout
      • How do I add additional container tag default options?
      • Showing Before and After Content even when field is empty
      • Getting started with the Advanced Elementor Widget for GravityView
      • Understanding the “Show Debug Output” option
      • How Move Featured Entries to Top works
      • Rank featured listings and sell featured spots
      • Getting started with Featured Entries
      • How to always display featured entries, regardless of search results
      • How to feature an entry using PHP
      • How to visually highlight featured entries in the Recent Entries widget
      • Show only featured entries in the Recent Entries widget
      • Style featured entries with CSS
      • Allowing users to delete entries when using a Magic Link
      • Fields not appearing in Edit Entry when using Magic Links?
      • Getting started with Magic Links
      • Magic Links filters
      • Preserving Magic Links parameters on password-protected Views
      • The {gv_magic_link} merge tag
      • Enabling 3D maps in the Maps Layout
      • My map won’t zoom in past a certain level
      • Showing distance and sorting by distance in radius search results
      • About custom map icons or markers
      • About GravityView Maps geocoding
      • Adding your Google Maps API Key into Divi
      • Adding your Google Maps API Key into Premium Addons for Elementor
      • Adding your Google Maps API Key into Ultimate Addons for Elementor
      • Associating a custom map pin icon (marker) with a field value
      • Can I use Maps to autocomplete addresses on my form?
      • Changing the address that GravityView Maps geocodes
      • Configuring info boxes in GravityView Maps
      • Enabling autocomplete for the Gravity Forms Address field
      • Enabling the REST API access
      • Error: Google Maps API warning: NoApiKeys
      • Error: This page can’t load Google Maps correctly
      • Fixing a conflict with UberMenu plugin
      • Getting started with the Maps Layout
      • Google Maps Javascript API Error “RefererNotAllowedMapError”
      • Granting Google Cloud Access to Support
      • How can I make the marker link to open in a new tab?
      • How can I pull the address from a field type that is not Address?
      • How do I display only the Map? I don’t want to display the entries under the Map.
      • How to enable and configure map marker clustering
      • How to enable radius search
      • How to hide map elements using CSS
      • How to override geocoding coordinates
      • How to show markers from multiple address fields on a map
      • Is it possible to style the map?
      • My map is gray and there are no entry markers
      • Radius Search: Request Location
      • Setting up Google Maps API keys for GravityView Maps
      • Support for OpenStreetMap or other map providers
      • Using a latitude and longitude fields to position the map markers
      • What are “Search as map moves” and “Redo search in map”?
      • Why aren’t some of my entries showing up on the map?
      • [Advanced] How to modify Ratings & Reviews entry comment titles
      • Changing the star titles shown on hover
      • Creating a review/voting system by embedding a form into a single entry (short)
      • Getting started with Ratings & Reviews
      • How to disable email notifications for reviews
      • Issue: GravityView Single Entry page only shows “Leave a Reply”
      • Ratings & Reviews Anonymous Reviews
      • Ratings & Reviews Hooks
      • Ratings & Reviews Merge Tags
      • Keeping Views with Prevent Direct Access out of XML sitemaps
      • Getting started with Social Sharing & SEO
      • Setting up SEO for Views with Yoast SEO
      • Setting up sharing buttons with JetPack
      • Getting started with PDF for GravityView
      • Using unions in Multiple Forms
      • Getting started with Multiple Forms
      • How to join a Nested Forms parent form to its child form
      • I don’t see the option to join multiple forms
      • Known limitations of Multiple Forms
      • Multiple Forms: How the “Strict Entry Match” setting works
      • Multiple Forms: Searching entries
      • Using Advanced Filtering with Multiple Forms
      • Why does my View show the same entry more than once?
      • Adding Live Filters to a View
      • Getting started with Connected Views
      • Using the Connections Map
      • Setting an editing deadline with Edit Window
    • Home
    • Docs
    • GravityView Pro
    • DataTables Layout
    • Customizing DataTables options in GravityView

    Customizing DataTables options in GravityView

    Estimated reading: 21 minutes

    Updated on November 27, 2026

    A DataTables View draws its table with the DataTables JavaScript library. Most of what the table does is set on the DataTables tab of the View’s Settings box, which Getting started with the DataTables Layout lists. For anything the tab doesn’t offer, you can change the library’s options with the PHP filters on this page.

    The main filter #

    The gravityview_datatables_js_options filter receives the DataTables settings of each DataTables View, just before the table is drawn. Every example on this page uses this shape:

    /**
     * Changes the DataTables settings of every DataTables View.
     *
     * @param array $dt_config The DataTables settings for the View.
     * @param int   $view_id   The ID of the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config, $view_id ) {
        // Change $dt_config here.
    
        return $dt_config;
    }, 20, 2 );

    Note: The PHP examples on this page go in your site’s code. Adding custom PHP code snippets to your website shows where.

    Keep the priority at 20. GravityView’s own DataTables settings change the same options at the default priority, 10, after your filter has run, so at 10 some changes are undone. A search box hidden at priority 10 comes back, and export buttons set at 10 show up next to the ones chosen in the View’s settings.

    The filter also passes the post the View is shown on and the DataTables class instance, which the examples don’t use. The developer reference for this filter describes all four.

    Note: A View with Save Table State turned on, the default, reopens the table the way each visitor last left it in that browser tab. A new default sort or page length then shows only in a new tab. The Save Table State setting in DataTables explains the setting.

    Changing only some Views #

    An example with no View ID check changes every DataTables View on your site. To change only some of them, check the View’s ID first.

    One View

    /**
     * Hides the DataTables search box on one View.
     *
     * @param array $dt_config The DataTables settings for the View.
     * @param int   $view_id   The ID of the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config, $view_id ) {
        // Replace 123 with the ID of your View.
        if ( 123 !== $view_id ) {
            return $dt_config;
        }
    
        $dt_config['searching'] = false;
    
        return $dt_config;
    }, 20, 2 );

    Several Views

    /**
     * Shows every entry on one page in three Views.
     *
     * @param array $dt_config The DataTables settings for the View.
     * @param int   $view_id   The ID of the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config, $view_id ) {
        // Replace these with the IDs of your Views.
        $target_views = [ 123, 456, 789 ];
    
        if ( in_array( $view_id, $target_views, true ) ) {
            $dt_config['paging'] = false;
        }
    
        return $dt_config;
    }, 20, 2 );

    Page length options #

    The Show entries menu above the table offers 10, 25, 50, All, and the View’s Number of entries per page, which is also the number the table opens with. Both can be changed in code.

    Using the menu’s own filter

    The gravityview_datatables_lengthmenu filter changes the menu’s choices. Each key is a number of entries and each value is what the menu shows for it. The key -1 shows every entry:

    /**
     * Changes the choices in the DataTables "Show entries" menu.
     *
     * @param array $values    Number of entries => menu label.
     * @param array $view_data The View's data.
     *
     * @return array The menu choices.
     */
    add_filter( 'gravityview_datatables_lengthmenu', function ( $values, $view_data ) {
        return [
            10  => 10,
            25  => 25,
            50  => 50,
            100 => 100,
            250 => 250,
            -1  => 'All',
        ];
    }, 10, 2 );

    Keep your View’s Number of entries per page among the keys, since the table still opens with that number.

    Using the main filter

    The main filter can set the menu and the first page length together. The menu then needs two lists, the numbers first and the labels second:

    /**
     * Sets the "Show entries" menu and opens the table with 25 entries.
     *
     * @param array $dt_config The DataTables settings for the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config ) {
        $dt_config['lengthMenu'] = [
            [ 10, 25, 50, 100, -1 ],      // Numbers of entries.
            [ 10, 25, 50, 100, 'All' ],   // What the menu shows.
        ];
    
        $dt_config['pageLength'] = 25;
    
        return $dt_config;
    }, 20 );

    With one list, such as [ 10, 25, 50, -1 ], the menu shows -1 where “All” should be.

    The DataTables search box #

    DataTables adds its own Search: box above the table of a View that has no Search Bar widget. A View with a Search Bar widget never shows it. To hide the box on every DataTables View:

    /**
     * Hides the DataTables search box on every DataTables View.
     *
     * @param array $dt_config The DataTables settings for the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config ) {
        $dt_config['searching'] = false;
    
        return $dt_config;
    }, 20 );

    The box goes, and a Search Bar widget and Field Filters keep working. Configuring the Search Bar widget covers the Search Bar.

    Pagination controls #

    Turning off pagination

    With paging off, the table shows every entry in one list and the Show entries menu goes away:

    /**
     * Shows every entry on one page, with no page links.
     *
     * @param array $dt_config The DataTables settings for the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config ) {
        $dt_config['paging'] = false;
    
        return $dt_config;
    }, 20 );

    Hiding the Show entries menu

    /**
     * Hides the "Show entries" menu. The page links stay.
     *
     * @param array $dt_config The DataTables settings for the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config ) {
        $dt_config['lengthChange'] = false;
    
        return $dt_config;
    }, 20 );

    Hiding the entry count

    /**
     * Hides the "Showing 1 to 10 of 64 entries" line.
     *
     * @param array $dt_config The DataTables settings for the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config ) {
        $dt_config['info'] = false;
    
        return $dt_config;
    }, 20 );

    Column sorting #

    Without code, the View’s Sort by field and Sort direction settings set the order the table opens in. How a DataTables View sorts its entries explains how the table sorts.

    Turning off sorting

    Visitors can no longer sort by clicking a column heading. The entries keep the View’s own sort order:

    /**
     * Turns off sorting by column headings.
     *
     * @param array $dt_config The DataTables settings for the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config ) {
        $dt_config['ordering'] = false;
    
        return $dt_config;
    }, 20 );

    Turning off sorting on one column

    Columns are counted from 0, left to right, in the order the table shows them:

    /**
     * Turns off sorting on the first column.
     *
     * @param array $dt_config The DataTables settings for the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config ) {
        if ( ! isset( $dt_config['columnDefs'] ) ) {
            $dt_config['columnDefs'] = [];
        }
    
        // Add to columnDefs. Never replace it.
        $dt_config['columnDefs'][] = [
            'targets'   => 0, // The first column.
            'orderable' => false,
        ];
    
        return $dt_config;
    }, 20 );

    Setting the default sort order

    This opens the table sorted by the third column, in descending order, in place of the View’s own sort settings:

    /**
     * Opens the table sorted by the third column, descending.
     *
     * @param array $dt_config The DataTables settings for the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config ) {
        $dt_config['order'] = [
            [ 2, 'desc' ], // Column 2 is the third column.
        ];
    
        return $dt_config;
    }, 20 );

    Opening with no column sorted

    With an empty order, no column heading is marked as sorted when the table opens. The entries still arrive in the View’s own sort order:

    /**
     * Opens the table with no column marked as sorted.
     *
     * @param array $dt_config The DataTables settings for the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config ) {
        $dt_config['order'] = [];
    
        return $dt_config;
    }, 20 );

    Column settings #

    The columnDefs option holds settings for single columns. Always add to it, as the examples below do.

    When a View sorts by a field that isn’t one of its columns, GravityView adds a hidden column for that field at the end of the table, through columnDefs. The hidden column has no heading and holds none of the field’s values.

    A snippet that replaces columnDefs makes it show up as an extra column at the right, with an empty heading. Its cells are empty in Ajax (Server-side) mode and hold numbers such as 0000000001 in Preloaded (Client-side) mode.

    Adding a CSS class to a column

    The class goes on the column’s heading and on each of its cells:

    /**
     * Adds a CSS class to the first column.
     *
     * @param array $dt_config The DataTables settings for the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config ) {
        if ( ! isset( $dt_config['columnDefs'] ) ) {
            $dt_config['columnDefs'] = [];
        }
    
        $dt_config['columnDefs'][] = [
            'targets'   => 0,                 // The first column.
            'className' => 'my-custom-class', // The CSS class.
        ];
    
        return $dt_config;
    }, 20 );

    Adding custom CSS to your Views shows where to put the CSS for that class.

    Hiding columns

    A hidden column still counts for the DataTables search box, so a search can match text in it. Export buttons leave hidden columns out of the file:

    /**
     * Hides the second and fourth columns of one View.
     *
     * @param array $dt_config The DataTables settings for the View.
     * @param int   $view_id   The ID of the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config, $view_id ) {
        // Replace 123 with the ID of your View.
        if ( 123 !== $view_id ) {
            return $dt_config;
        }
    
        if ( ! isset( $dt_config['columnDefs'] ) ) {
            $dt_config['columnDefs'] = [];
        }
    
        $dt_config['columnDefs'][] = [
            'targets' => [ 1, 3 ], // The second and fourth columns.
            'visible' => false,
        ];
    
        return $dt_config;
    }, 20, 2 );

    Column widths

    Set widths in the View editor: each field in Visible Table Columns has a Percent Width setting, and Controlling column widths and pinning columns in DataTables explains it. A width added through columnDefs changes nothing, because GravityView sets every column’s width itself.

    The Loading data message #

    While the table fetches entries, it shows a Loading data… message. In the Ajax (Server-side) processing mode, this turns the message off:

    /**
     * Turns off the "Loading data…" message (Ajax mode only).
     *
     * @param array $dt_config The DataTables settings for the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config ) {
        $dt_config['processing'] = false;
    
        return $dt_config;
    }, 20 );

    A View in the Preloaded (Client-side) mode still shows the message. How to disable the “Loading data” message hides it with CSS in both modes.

    To change the message’s words instead:

    /**
     * Changes the words of the "Loading data…" message.
     *
     * @param string   $text The message. Default: "Loading data…".
     * @param \GV\View $view The View.
     *
     * @return string The new message.
     */
    add_filter( 'gravityview_datatables_loading_text', function ( $text, $view ) {
        return 'Loading the attendee list…';
    }, 10, 2 );

    Export buttons #

    The Buttons setting on the DataTables tab chooses which export buttons show above the table, and Buttons (DataTables Setting) explains each one. The examples below need that setting on.

    CSV files and UTF-8

    The CSV button already saves the file as UTF-8, with a byte order mark and a heading row, so the encoding needs no code. To change the separator, see How to change the separator in DataTables CSV exports.

    PDF title and file name

    To change the PDF file’s title and name, use the PDF button’s own filter. It works when PDF is ticked under Buttons:

    /**
     * Changes the title and file name of one View's PDF export.
     *
     * @param array $button  The PDF button's settings.
     * @param int   $view_id The ID of the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview/datatables/button_pdf', function ( $button, $view_id ) {
        // Replace 123 with the ID of your View.
        if ( 123 !== $view_id ) {
            return $button;
        }
    
        $button['title']    = 'Conference attendees';
        $button['filename'] = 'attendees';
    
        return $button;
    }, 10, 2 );

    The title is printed above the table, and the file is saved as attendees.pdf.

    Choosing the buttons in code

    Set the buttons option to choose the buttons in code. Your list replaces the buttons ticked in the View’s settings:

    /**
     * Shows CSV (no heading row), PDF (with a title), and Print buttons.
     *
     * @param array $dt_config The DataTables settings for the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config ) {
        $dt_config['buttons'] = [
            [
                'extend' => 'csv',
                'header' => false, // No heading row in the file.
            ],
            [
                'extend' => 'pdfHtml5',
                'title'  => 'Conference attendees',
            ],
            [
                'extend' => 'print',
            ],
        ];
    
        return $dt_config;
    }, 20 );

    Changing the table’s text #

    The View’s No Entries Message and “No Search Results” Text settings change the message in an empty table without code, as Modifying the text displayed when there are no entries shows. This filter changes those messages and the table’s other words:

    /**
     * Changes the words DataTables shows around the table.
     *
     * @param array $language The DataTables text, by key.
     *
     * @return array The changed text.
     */
    add_filter( 'gravityview/datatables/config/language', function ( $language ) {
        // The View has no entries.
        $language['zeroRecords'] = 'No attendees have registered yet.';
    
        // A search found nothing.
        $language['emptyTable'] = 'No attendees match your search.';
    
        $language['info']      = 'Showing _START_ to _END_ of _TOTAL_ attendees';
        $language['infoEmpty'] = 'No attendees to show';
        $language['search']    = 'Find an attendee:';
    
        return $language;
    } );

    In GravityView, zeroRecords is the message for a View with no entries and emptyTable the message for a search that finds nothing. The filter’s text replaces both View settings.

    In DataTables 3.15.2 or newer, zeroRecords and emptyTable are shown as HTML, so they can hold a link. Plain text that contains < or & needs esc_html() to show as typed. Without it, the browser reads <name> as a tag and drops it:

    /**
     * Links the no-entries message and escapes the no-results message.
     *
     * @param array $language The DataTables text, by key.
     *
     * @return array The changed text.
     */
    add_filter( 'gravityview/datatables/config/language', function ( $language ) {
        // HTML: the link works.
        $language['zeroRecords'] = 'No attendees have registered yet. '
            . '<a href="https://example.com/register/">Register for the conference</a>.';
    
        // Plain text with < and >: esc_html() shows them as typed.
        $language['emptyTable'] = esc_html(
            'No attendee matches that search. Search by <name> or <company>.'
        );
    
        return $language;
    } );

    Field Filters hint text #

    When DataTables Field Filters are on, this changes the hint in each text and drop-down filter. A date filter has none. A text filter shows the hint inside the box, and a drop-down filter shows it as its first choice:

    /**
     * Changes the hint text of DataTables Field Filters.
     *
     * @param string $placeholder The hint. Default: "Filter by" and the column's label.
     * @param string $field_label The column's label.
     *
     * @return string The new hint.
     */
    add_filter(
        'gravityview/datatables/field_filters/placeholder',
        function ( $placeholder, $field_label ) {
            return 'Search by ' . $field_label . '...';
        },
        10,
        2
    );

    Complete examples #

    A table with no controls

    This table has no search box, Show entries menu, entry count, page links, or sorting. Export buttons still show while the Buttons setting is on, so turn it off on the DataTables tab for a table with no controls at all.

    /**
     * Shows one View as a plain table: every entry, no search, sorting or paging.
     *
     * @param array $dt_config The DataTables settings for the View.
     * @param int   $view_id   The ID of the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config, $view_id ) {
        // Replace 123 with the ID of your View.
        if ( 123 !== $view_id ) {
            return $dt_config;
        }
    
        $dt_config['searching']    = false; // No search box.
        $dt_config['lengthChange'] = false; // No "Show entries" menu.
        $dt_config['ordering']     = false; // No sorting.
        $dt_config['info']         = false; // No "Showing 1 to 10 of 64 entries" line.
        $dt_config['paging']       = false; // Every entry on one page.
    
        return $dt_config;
    }, 20, 2 );
    A table of conference attendees with no buttons, search box, entry count, or page links above or below it

    Larger page lengths

    /**
     * Offers larger page lengths and opens the table with 100 entries.
     *
     * @param array $dt_config The DataTables settings for the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config ) {
        $dt_config['lengthMenu'] = [
            [ 25, 50, 100, 250, 500, -1 ],
            [ 25, 50, 100, 250, 500, 'All' ],
        ];
    
        $dt_config['pageLength'] = 100;
    
        return $dt_config;
    }, 20 );

    An export-ready table

    /**
     * Gives one View CSV, PDF, and Print buttons and 50 entries a page.
     *
     * @param array $dt_config The DataTables settings for the View.
     * @param int   $view_id   The ID of the View.
     *
     * @return array The changed settings.
     */
    add_filter( 'gravityview_datatables_js_options', function ( $dt_config, $view_id ) {
        // Replace 123 with the ID of your View.
        if ( 123 !== $view_id ) {
            return $dt_config;
        }
    
        $dt_config['buttons'] = [
            [ 'extend' => 'csv' ],
            [ 'extend' => 'pdfHtml5', 'title' => 'Conference attendees' ],
            [ 'extend' => 'print' ],
        ];
    
        $dt_config['order'] = [];
    
        $dt_config['lengthMenu'] = [
            [ 25, 50, 100, -1 ],
            [ 25, 50, 100, 'All' ],
        ];
    
        $dt_config['pageLength'] = 50;
    
        return $dt_config;
    }, 20, 2 );
    A table of conference attendees with CSV, PDF, and Print buttons and the Show entries menu set to 50

    Options reference #

    OptionTypeWhat it changes
    lengthMenuarrayThe choices in the Show entries menu. Use two lists to show “All”.
    pageLengthintHow many entries the table opens with.
    lengthChangeboolfalse hides the Show entries menu.
    pagingboolfalse shows every entry on one page.
    searchingboolfalse hides the DataTables search box.
    orderingboolfalse turns off sorting by column headings.
    infoboolfalse hides the “Showing 1 to 10 of 64 entries” line.
    processingboolfalse turns off the Loading data… message in Ajax (Server-side) mode.
    orderarrayThe column and direction the table opens sorted by.
    columnDefsarraySettings for single columns. Add to it, never replace it.
    buttonsarrayThe export buttons. Replaces the buttons ticked in the View’s settings.

    The DataTables options reference lists every option the library has.

    Still stuck?

    How can we help?

    "*" indicates required fields

    This field is for validation purposes and should be left unchanged.
    Replies will go to this email.
    How can we help?*
    My pre-sale question is related to...*
    My WordPress skills are....*
    My Gravity Forms skills are...*
    You will be shown articles from our documentation.
    Vous pouvez nous écrire dans votre langue maternelle si c’est plus facile pour vous—nous nous occuperons de la traduction!
    Puedes escribirnos en tu idioma nativo si te resulta más fácil; ¡nosotros nos encargamos de la traducción!
    Sie können uns in Ihrer Muttersprache schreiben, wenn das für Sie einfacher ist – wir kümmern uns um die Übersetzung!
    U kunt ons in uw moedertaal schrijven als dat gemakkelijker voor u is — wij zorgen voor de vertaling!
    Du kan skrive til oss på ditt morsmål hvis det er enklere for deg — vi tar oss av oversettelsen!
    Du kan skriva till oss på ditt modersmål om det är lättare för dig — vi tar hand om översättningen!
    Você pode nos escrever em seu idioma nativo se for mais fácil para você — nós cuidaremos da tradução!
    Puoi scriverci nella tua lingua madre se ti è più facile — penseremo noi alla traduzione!
    Please provide as much detail as you're able; this helps us provide you with faster support.
    Drop files here or
    Accepted file types: jpg, jpeg, gif, png, tiff, pdf, bmp, zip, json, csv, xls, xlsx, Max. file size: 256 MB.
      Get better at Gravity Forms every Friday

      Was this page helpful?

      Table Of Contents
      • The main filter
      • Changing only some Views
      • Page length options
      • The DataTables search box
      • Pagination controls
      • Column sorting
      • Column settings
      • The Loading data message
      • Export buttons
      • Changing the table’s text
      • Field Filters hint text
      • Complete examples
      • Options reference
      GravityKit
      • How to Build It
      • GravityKit vs competitors
      • Pricing
      • Products
      • Our Team
      • Our Values
      • Work With Us
      • Partner Directory
      • Coupons
      Support
      • Support
      • Contact
      • Documentation
      • Scope of Support
      • Brand Guidelines
      • Brand Kit
      • Privacy Policy
      • Terms of Service (“Terms”)
      I am a...
      • Nonprofit
      • Web agency
      • Small business owner
      • Web developer
      • Educational institution
      • WordPress freelancer
      • Startup founder
      • One-person agency
      Get notified of updates.

      We’re constantly improving GravityKit. Fill out your email below and we’ll notify you anytime major updates drop.

      See past editions
      • Facebook
      • Twitter
      • Mastodon
      GravityKit is a Gravity Forms Certified Developer.

      Copyright © 2026, Katz Web Services, Inc.

      GravityKit and GravityView are registered trademarks of Katz Web Services, Inc.