Jsf 获取行id数据表primefaces
我有一个类似于上面代码的数据表,如您所见,我使用事件rowSelectedcheckBox,有没有办法知道单击的行,并根据该信息完全禁用该行Jsf 获取行id数据表primefaces,jsf,jsf-2,primefaces,datatable,Jsf,Jsf 2,Primefaces,Datatable,我有一个类似于上面代码的数据表,如您所见,我使用事件rowSelectedcheckBox,有没有办法知道单击的行,并根据该信息完全禁用该行 <p:dataTable id="tblTipoCarteraGeneric" style="text-align:left;" value="#{alertasPredefinidasModel.tipoCarteraDTOs}" var="tipoCarter
<p:dataTable id="tblTipoCarteraGeneric" style="text-align:left;"
value="#{alertasPredefinidasModel.tipoCarteraDTOs}"
var="tipoCartera"
rows="15" paginator="true"
emptyMessage="empty"
paginatorAlwaysVisible="true"
paginatorPosition="bottom"
selection="#{alertasPredefinidasModel.elementoSeleccionado.tipoCarteraDTOs}"
rowKey="#{tipoCartera.tipoCarteraDTO.tipocarteraID}"
rendered="#{alertasPredefinidasModel.isTipoCartera()}">
<p:ajax event="rowSelectCheckbox" update=":form:tblTipoCarteraGeneric, :form:messages"
listener="#{alertasPredefinidasController.onRowSelected}"/>
<p:ajax event="rowUnselectCheckbox" update=":form:tblTipoCarteraGeneric, :form:messages"
listener="#{alertasPredefinidasController.onRowUnselected}"/>
<p:column selectionMode="multiple" styleClass="selection-column no-all"
disabledSelection="#{alertasPredefinidasModel.modoDetalle}"/>
<p:column headerText="Tipo de cartera" styleClass="wrappedText" >
<h:outputText id="inTxtCol1" value="#{tipoCartera.tipoCarteraDTO.nombre}" />
</p:column>
<p:column headerText="Valor del abono" styleClass="wrappedText" rendered="#{alertasPredefinidasModel.isTipoCarteraConValorOpcion2()}">
<h:inputText id="inTxtCol2" value="#{tipoCartera.parametro1}" style="width:100%"
disabled="#{alertasPredefinidasModel.modoDetalle}"/>
<pe:tooltip myPosition="top center" atPosition="bottom right" for="inTxtCol2"
value="#{tooltips.obtainToolTip('parametrizarAlertasPredefinidas', 'inTxtCol2', 'es', 'itac.SIT-Core-Middleware-Sarlaft-WAR.tooltip')} "/>
</p:column>
<p:column headerText="Porcentaje superior al valor del abono" styleClass="wrappedText" rendered="#{alertasPredefinidasModel.isTipoCarteraConValorOpcion2()}">
<h:inputText id="inTxtCol3" value="#{tipoCartera.parametro2}" style="width:100%"
disabled="#{alertasPredefinidasModel.modoDetalle}"/>
<pe:tooltip myPosition="top center" atPosition="bottom right" for="inTxtCol3"
value="#{tooltips.obtainToolTip('parametrizarAlertasPredefinidas', 'inTxtCol3', 'es', 'itac.SIT-Core-Middleware-Sarlaft-WAR.tooltip')} "/>
</p:column>
</p:dataTable>
您可以使用Datatable的rowIndex属性。您可以在StyleClass中使用rowIndex,并在单击调用javascript方法时进行绑定。通过将具有rowIndex的类获取行 你也可以参考这个
我认为这将满足您的要求。我在您的
中添加了一个额外属性styleClass=“tblTipoCarteraGeneric”
,并添加了两个
事件页面
(因为在页面更改后,上一页的用户交互记录保持不变)和切换选择
(如果用户选择标题复选框而不是使用每行的单格复选框)
假设您的
是这样包装的:
<h:form>
<p:dataTable id="tblTipoCarteraGeneric" styleClass="tblTipoCarteraGeneric" ......>
<p:ajax event="rowSelectCheckbox" oncomplete="abcd()" />
<p:ajax event="page" oncomplete="abcd()" />
<p:ajax event="toggleSelect" oncomplete="abcd()" />
<p:column></p:column>
..
..
..
<p:column></p:column>
</p:dataTable>
<h:outputScript>var abcd = function(){
$('div.tblTipoCarteraGeneric >div > table > tbody > tr').each(function(){
if($(this).hasClass('ui-state-highlight')){
$(this).css({'pointer-events': 'none'});
} else {
$(this).css({'pointer-events': 'auto'});
}
});
};
</h:outputScript>
</form>
..
..
..
var abcd=函数(){
$('div.tblTipoCarteraGeneric>div>table>tbody>tr')。每个(函数(){
if($(this).hasClass('ui-state-highlight')){
$(this.css({'pointer-events':'none'});
}否则{
$(this.css({'pointer-events':'auto'});
}
});
};
您想要什么?是否要禁用选定的行?禁用行后,将无法启用该行。这是您的要求吗?就像“切换”(选中时,将激活输入文本;未选中时,将被禁用)感谢您的响应,我更希望采用primefaces方式的解决方案(即没有硬编码javascript)@Chechus根据我的说法,
中没有可以禁用、启用行的属性。因此,在不使用javascript的情况下,无法禁用、启用
的行。如果你有更好的办法,请告诉我。非常感谢。