Search code examples
gridjs

Can't change the pagination 'next' and 'prev' labels to my language in grid.js


There is no such option as change the prev and next button label in the documentation, and when i try to use string replacement or change the button innerHTML via Javascript, it doesn't work, is there any way that I can safely change the label?


Solution

  • You can use the language config (added since v1.5.0) to customize this:

    new Grid({
      columns: ['Name', 'Email', 'Title'],
      sort: true,
      search: true,
      pagination: {
        limit: 5
      },
      data: Array(50).fill().map(x => [
        faker.name.findName(),
        faker.internet.email(),
        faker.name.title(),
      ]),
      language: {
        'search': {
          'placeholder': '🔍 Search...'
        },
        'pagination': {
          'previous': '⬅️',
          'next': '➡️',
          'showing': '😃 Displaying'
        }
      }
    });
    

    Also see this example: https://gridjs.io/docs/examples/i18n/