JSF Extended Datatable Sorting and Filtering

余生长醉 提交于 2019-12-11 13:34:00

问题


I have a extended datatable, RICHFACES 3.3.3 with sorting and filtering enabled. The table is rendered dynamically. Based on the requirement, I need to disable certain rows(which contain editable fields) when the table is displayed.

I have that logic written in a Javascript function rowBlur(), and call it whenever the page is displayed. Hence, when the table is loaded the required rows are disabled as expected. The problem is whenever I filter/sort the table, the disabled rows get enabled again.

Is there any way I can call the javascript function whenever filter or sort happens?

Here is the code:

HtmlExtendedDataTable dynamicDataTable = new HtmlExtendedDataTable();
dynamicDataTable.setOnkeydown("filterAllOnEnter(event)");

function filterAllOnEnter(event) {
    if(event.keyCode == 13) {
        jQuery(".rich-filter-input").blur();
        rowblur();
        return false;
    } else
        return true;
}

// js code////////////
<script>
function show(){
    val = '${myController.mergeWorkMap}';
}
</script>
<script>
function rowblur(){
for(var i=0;i<7;i++){
    var firstCol = "myForm:dynamicTable:"+i+":col0" ;
    var secondCol = "myForm:dynamicTable:"+i+":col1" ;
    var merge =document.getElementById(firstCol).textContent;
    var work =document.getElementById(secondCol).textContent;
    var obj = JSON.parse(val).mergeWorkMap;
    if(!(work == obj[merge])){
        var col3 = "myForm:dynamicTable:" + i + ":col3";
        var col4 = "myForm:dynamicTable:" + i + ":col4";
        var col5 = "myForm:dynamicTable:" + i + ":col5";
        var col6 = "myForm:dynamicTable:" + i + ":col6";
        document.getElementById(col3).disabled = true;
        document.getElementById(col4).disabled = true;
        document.getElementById(col5).disabled = true; 
        document.getElementById(col6).disabled = true;
    }

}
}
</script>

The rowblur() won't work properly on filtering, and on sorting the columns it won't work at all.

来源:https://stackoverflow.com/questions/14628047/jsf-extended-datatable-sorting-and-filtering

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!