【问题标题】:How to update datatable value after checked or unchecked the checkbox选中或取消选中复选框后如何更新数据表值
【发布时间】:2015-07-21 06:24:29
【问题描述】:

我有以下代码,当我选中复选框时,该值不会反映在 dtWebVo.cpdCourseInfo[??].chkSelect 中。因为我想在数据库中获取值和更新。我该怎么办??

  <p:dataTable var="cpdCourseInfoDetail" tableStyle="width:auto" 
                                value="#{dtWebVo.cpdCourseInfo}"
                                rowKey="#{cpdCourseInfoDetail.selfInputCourseID}"
                                 selection="#{dtWebVo.selectedCPDCourseInfo}" rowIndexVar="index"
                                 id="gridCourseInfo"  styleClass="ui-edb-td-wrap-table ui-edb-header-style table-no-select-all" >
                            <p:column>
                                <p:selectBooleanCheckbox value="#{cpdCourseInfoDetail.chkSelect}"
                                disabled="#{cpdCourseInfoDetail.getDisableCheckBox()}" >
                                </p:selectBooleanCheckbox>
                        </p:column>

【问题讨论】:

  • 我正在尝试使用下面的代码。但是禁用复选框不起作用。
  • 请删除您所有的 cmets 并回答并编辑原始问题。以这种方式碎片化的方式

标签: primefaces datatable


【解决方案1】:
<p:dataTable var="cpdCourseInfoDetail" tableStyle="width:auto" 
    value="#{dtWebVo.cpdCourseInfo}"
    rowKey="#{cpdCourseInfoDetail.selfInputCourseID}"
    rowIndexVar="index" selection="#{dtWebVo.selectedCPDCourseInfo}"
    id="gridCourseInfo"  styleClass="ui-edb-td-wrap-table ui-edb-header-style table-no-select-all" >
   <p:column id="x_checkbox" selectionMode="multiple" onload="disableCheckBox(this.id,#{cpdCourseInfoDetail.cpdStatusAction})"></p:column>

【讨论】:

  • 我正在尝试使用上述代码但禁用复选框失败。
  • function disableCheckBox(id, checkStatus){ if(checkStatus=='Submitted') document.getElementById(id).disabled='true';否则 document.getElementById(id).disabled='false'; }
【解决方案2】:

通过在 datatable 标记中放入下面来修复。

<p:dataTable disabledSelection="#{car.color =='Black'}" ... >

【讨论】:

  • 对不起,这个问题和答案对任何人都毫无用处。什么都无法理解。请全部删除。
猜你喜欢
  • 2018-06-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-09-25
  • 2022-07-07
  • 1970-01-01
  • 1970-01-01
  • 2014-08-01
相关资源
最近更新 更多