简体   繁体   English

primefaces:可编辑数据表中的不可编辑列

[英]primefaces: uneditable columns in editable datatable

I have an editable dataTable, I want to add checkbox to the header which controls the editable mode of the column. 我有一个可编辑的dataTable,我想在复选框中添加复选框以控制列的可编辑模式。 which mean, every column has a checkbox in it's header, if the checkbox is selected the columns will be uneditable, which means we can not edit any data in the cells. 这意味着每个列的标题中都有一个复选框,如果选中该复选框,则这些列将不可编辑,这意味着我们无法编辑单元格中的任何数据。

how can I do that ?? 我怎样才能做到这一点 ??

thanks 谢谢

Create a variable of type boolean for each column 为每列创建一个布尔类型的变量

 <p:selectBooleanCheckbox  value="#{Yourbean.EditableColumn1}" />
 <p:selectBooleanCheckbox  value="#{Yourbean.EditableColumn2}" />
 <p:selectBooleanCheckbox  value="#{Yourbean.EditableColumn3}" />

Let's say you want to have inputText boxes in your column values, you may control if it's editable by the disabled attribute. 假设您要在列值中包含inputText框,则可以控制它是否可以由Disabled属性编辑。

 <p:dataTable>
   <p:column id="column1">
      <h:inputText disabled="#{YourBean.EditableColumn1}">
   </p:column>
   <p:column id="column2">
      <h:inputText disabled="#{YourBean.EditableColumn2}">
   </p:column>
   <p:column id="column3">
      <h:inputText disabled="#{YourBean.EditableColumn3}">
   </p:column>
 </p:dataTable>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM