English 中文(简体)
总理:我如何检查一页:与选择Mode=“多彩”相容?
原标题:PrimeFaces: how can I check a p:column with selectionMode="multiple"?

I have a <p:dataTable> with a <p:column selectedMode=“multiple”/>。 当我在数据表上显示一个single row时,我希望我申请自动核对这一句。 (以及表头上显示的“检查器”检查箱。)

我通过 Java做了这项工作,并视力做了工作。 然而,在提交表格时,似乎提交的“支票”价值为吨。 如果我两次在检查箱上点击(去除并再次检查),检查箱就行了。

JSF:

<p:dataTable var="invoiceGroup"
             selection="#{chargeBean.selectedInvoiceGroupBeans}"
             value="#{chargeBean.invoiceGroupList}"
             rowKey="#{invoiceGroup.id}">
    <p:column selectionMode="multiple" />
    ...
</p:dataTable>

<Javascript Code:

function selectTableElements() {
    var checkBoxes = $( #invoiceGroupTable td.ui-selection-column input[type="checkbox"] );
    var paginatorPages = $( #invoiceGroupTable .ui-paginator .ui-paginator-pages .ui-paginator-page ); 
    if (checkBoxes.length === 1 && paginatorPages.length === 1) {
        setTimeout(function () {
            $( #invoiceGroupTable th input[type="checkbox"] ).click();
        }, 10);
    }
}

是否有办法利用这一服务器?

问题回答

Firstly, I would prefer a multiple selection dataTable without checkboxes(multiple select just with CTRL key http://www.primefaces.org/showcase-labs/ui/datatableRowSelectionMultiple.jsf ).

Secondly, I don t know why you don t check(in server side) if the list(invoiceGroupList) has only a member/object and add it automatically to the second list, the selectedInvoiceGroupBeans. If you still want this to be also visually, you can keep your javascript/jquery function that already does it s job. Also you can take a look at the Primefaces RequestContext component: you can call javascript functions from server side, if you want some more interesting visual design, for example that row to be selected or even highlighted after running the action method - http://www.primefaces.org/showcase-labs/ui/requestContext.jsf.

第三,为什么你使用<条码>日标/代码>javascript功能? 如果您推导出一份<条码>commandButton,该编码即提交,并点击您的javascript功能,则纽伦首先将提交,然后选择检查箱,并以此赢得预期行为。





相关问题
Remove all columns with no data from DataTable

If all the items for a particular column are empty, I want to remove that column from the DataTable. What s the most elegant way to do this operation on all columns in the DataTable?

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Customize DataColumn.Expression handling in C#

I would like to change behavior of DataColumn.Expression so that when I write: DataColumn.Expression = "MyMethod(Price)" It will call MyMethod, pass value from Price column into it and display ...

热门标签