Primefaces datatable roweditor: only permit one row editing

前端 未结 2 634
轮回少年
轮回少年 2020-12-25 14:21

I\'m working with JSF 2.1.6 and Primefaces 3.4.1 and I have a question.

I have an editable datatable with row editor. You can click the pencil button of each row, an

相关标签:
2条回答
  • 2020-12-25 14:30

    You need to iterate through the elements, and cancel any other edit.

    $('.myTableStyle tbody.ui-datatable-data tr td span.ui-row-editor span.ui-icon-cancel').each(function(){
      $(this).click();
    });
    
    0 讨论(0)
  • 2020-12-25 14:39

    The above solution is not working for me. As an alternativ solution, I just hide the edit-button (pencil) when I'm editing a row with css

    <p:ajax event="rowEditInit" oncomplete="$('.ui-row-editor span.ui-icon-pencil').each(function(){$(this).css('visibility','hidden')});" />
    
    <p:ajax event="rowEdit" oncomplete="$('.ui-row-editor span.ui-icon-pencil').each(function(){$(this).css('visibility','visible')});"/>   
    
    <p:ajax event="rowEditCancel" onstart="$('.ui-row-editor span.ui-icon-pencil').each(function(){$(this).css('visibility','visible')});"/>
    
    0 讨论(0)
提交回复
热议问题