Показать / скрыть столбец в rich: extendedDataTable (RichFaces 4.x) - PullRequest
1 голос
/ 25 июля 2011

Функция отображения / скрытия столбца RichFaces для rich:extendedDataTable больше не доступна для версии 4.x. Есть идеи, как это реализовать другим способом?

Я пытался сделать это с помощью JavaScript, с функцией document.getElementById() и установкой свойства элемента style.display, но трудно найти элемент по id, поскольку все элементы в rich:table генерируются динамически.

Любая помощь и советы будут оценены.

Ответы [ 3 ]

1 голос
/ 05 марта 2013

В Richfaces 4.x extendedDataTable вы можете использовать стиль css для одновременного управления заголовком и телом этого столбца. Стиль css каждого столбца создается с префиксом ".rf-edt-c-" и идентификатором столбца. Если у вас есть столбец с идентификатором «column1», стиль css будет «.rf-edt-c-column1». Ниже приведен пример, чтобы скрыть / показать столбец с идентификатором столбца в Java Script.

<script type="text/javascript">
//<![CDATA[ 

    function hideColumn(columnId)
    {
        var styleSheets = document.styleSheets;
        for(var i=0;i<styleSheets.length;i++)
        {
            var rules = null;

            // IE and Chrome
            if(styleSheets[i].rules != null)
            {
                rules = styleSheets[i].rules;
            }
            // Firefox
            else if(styleSheets[i].cssRules != null)
            {
                rules = styleSheets[i].cssRules;
            }

            for(var j=0;j<rules.length;j++)
            {
                // Find the css style of that column
                if(rules[j].selectorText==".rf-edt-c-" + columnId)
                {
                    rules[j].style.display = "none";
                }
            }
        }
    }

    function showColumn(columnId)
    {
        var styleSheets = document.styleSheets;
        for(var i=0;i<styleSheets.length;i++)
        {
            var rules = null;

            // IE and Chrome
            if(styleSheets[i].rules != null)
            {
                rules = styleSheets[i].rules;
            }
            // Firefox
            else if(styleSheets[i].cssRules != null)
            {
                rules = styleSheets[i].cssRules;
            }

            for(var j=0;j<rules.length;j++)
            {
                // Find the css style of that column
                if(rules[j].selectorText==".rf-edt-c-" + columnId)
                {
                    rules[j].style.display = "";
                }
            }
        }
    }

//]]>
</script>
0 голосов
/ 08 июня 2015

Я добавляю это в rich:column атрибуты:

width="#{myBean.testDisplay('toDisplay')?'':'0px;border:none;'}"

Это лучше, чем использовать rendered, потому что rendered ошибки с перестановкой столбцов.

0 голосов
/ 13 июля 2012

Просто поместите атрибут visible="false" в тег the rich:column следующим образом:

<rich:column id="name" label="Name" sortable="true" sortBy="#{edt.name}" visible="false">

Неправильная версия RichFaces, извините.

...