p:datatable sort language with responsive reflow = “true”

前端 未结 2 1261
忘掉有多难
忘掉有多难 2021-01-24 09:46

How can I change the language for Sorting on PF DataTable component with reflow = \"true\" (so responsive Datatable)?

The problem is that on mobile screen, we can sort d

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-24 10:04

    I never ran into this or used it, but I know the source is open. So I went to the javascript file for the datatable. There I searched for 'Ascending' and via this.ascMessage, I ended up on line 170 where 'datatable.sort.ASC' is used as a key.

    This in turn points to line 619 in core.js

    getAriaLabel: function(key) {
            var ariaLocaleSettings = this.getLocaleSettings()['aria'];
            return (ariaLocaleSettings&&ariaLocaleSettings[key]) ? ariaLocaleSettings[key] : PrimeFaces.locales['en_US']['aria'][key];
    },
    

    Where you can see the normal PrimeFaces locale functionality is used.

    So using your own locale and overriding this part in it, like in the default locale

    aria: {
        'paginator.PAGE': 'Page {0}',
        'calendar.BUTTON': 'Show Calendar',
        'datatable.sort.ASC': 'activate to sort column ascending',
        'datatable.sort.DESC': 'activate to sort column descending',
        'columntoggler.CLOSE': 'Close'
    }
    

    Will solve your issue I would expect

提交回复
热议问题