2016-06-20 4 views
2

У меня есть простой графический интерфейс Primefaces с SummaryRow. Значения этого SummaryRow вычисляются в ManagedBean и доступны в простых переменных BigDecimal. DataTable упорядочивается по строкам.Сводка строк Сводка строк в нескольких строках

Как-то отображается DataTable с summaryRow в каждой строке, а не в последней строке.

Я искал это, но ничего не нашел.

Я использую Primefaces 5.3 с JSF 2.2.

В таблице: (https://drive.google.com/file/d/0Bw9aJmydXWmvdU8yTUkyYnp0Ums/view)

XHTML:

<p:dataTable 
id="rgmStoricoContrattiSogettoCapogruppoDataTable" 
value="#{storicoSoggettoProdottoBean.sogegettoProdottoList}" 
var="soggetto" 
rendered="#{storicoSoggettoProdottoBean.isNdgMemberOfGroup()}" 
styleClass="common_datagrid" 
emptyMessage="Nessun valore presente" 
sortBy="#{soggetto.denominazione}" > 

<p:column headerText="Soggetto"> 
    <p:commandLink 
     value="#{soggetto.denominazione} #{soggetto.ndg} - #{soggetto.ndgCapogruppo}" 
     actionListener="#{storicoSoggettoProdottoBean.redirectSoggetoProdotto(request.contextPath, soggetto)}" 
     immediate="true" 
     process="@this" 
     style="font-size: 11px !important;" /> 
</p:column> 

<p:column headerText="Rating And./Cerved" width="67" style="text-align: center"> 
    <h:outputText value="#{soggetto.rating}/#{soggetto.ratingCerved}" /> 
</p:column> 

<p:column headerText="Perfez. storico" width="60" style="text-align: right"> 
    <h:outputText value="#{soggetto.perfezionato}"> 
     <f:convertNumber type="currency" currencySymbol="€"/> 
    </h:outputText> 
</p:column> 

<p:column headerText="Accord." width="60" style="text-align: right"> 
    <h:outputText value="#{soggetto.accordato}"> 
     <f:convertNumber type="currency" currencySymbol="€"/> 
    </h:outputText> 
</p:column> 

<p:column headerText="Utilizz." width="60" style="text-align: right"> 
    <h:outputText value="#{soggetto.utilizzato}"> 
     <f:convertNumber type="currency" currencySymbol="€"/> 
    </h:outputText> 
</p:column> 

<p:column headerText="Sconfino" width="60" style="text-align: right"> 
    <h:outputText value="#{soggetto.sconfino}"> 
     <f:convertNumber type="currency" currencySymbol="€"/> 
    </h:outputText> 
</p:column> 

<p:column headerText="In proposta" width="60" style="text-align: right"> 
    <h:outputText value="#{soggetto.inProposta}"> 
     <f:convertNumber type="currency" currencySymbol="€"/> 
    </h:outputText> 
</p:column> 

<p:column headerText="Garanzie bancarie" width="60" style="text-align: right"> 
    <h:outputText value="#{soggetto.garanzieBancarie}"> 
     <f:convertNumber type="currency" currencySymbol="€"/> 
    </h:outputText> 
</p:column> 

<p:column headerText="Rischio indiretto vs gruppo" width="87" style="text-align: center;"> 
    <h:outputText rendered="#{soggetto.rischioIndirettoVsGruppo == true}" value="SÍ" style="color: green; font-weight: bold;" /> 
</p:column> 

<p:column headerText="Rischio indiretto vs terzi" width="60" style="text-align: right"> 
    <h:outputText value="#{soggetto.rischioIndirettoVsTerzi}"> 
     <f:convertNumber type="currency" currencySymbol="€"/> 
    </h:outputText> 
</p:column> 

<p:column headerText="Rischio pond." width="60" style="text-align: right"> 
    <h:outputText value="#{soggetto.rischioPonderato}"> 
     <f:convertNumber type="currency" currencySymbol="€"/> 
    </h:outputText> 
</p:column> 

<p:column width="25"> 
    <p:commandButton 
     action="#{storicoSoggettoProdottoBean.redirectToStoricoPlafond(request.contextPath, soggetto)}" 
     immediate="true" 
     process="@this" 
     icon="fa fa-file-text-o" 
     styleClass="imageButton" 
     style="height: 12px;" /> 
</p:column> 

<p:summaryRow> 
    <p:column styleClass="totaleRowColor" style="text-align: right;"> 
     <h:outputText value="Totale:" style="font-weight: bold; text-transform: uppercase;" /> 
    </p:column> 

    <p:column styleClass="totaleRowColor" width="67" /> 

    <p:column styleClass="totaleRowColor" style="text-align: right;" width="60"> 
     <h:outputText value="#{storicoSoggettoProdottoBean.perfezionatoSoggettoSum}"> 
      <f:convertNumber type="currency" currencySymbol="€"/> 
     </h:outputText> 
    </p:column> 

    <p:column styleClass="totaleRowColor" style="text-align: right;" width="60"> 
     <h:outputText value="#{storicoSoggettoProdottoBean.accordatoSoggettoSum}"> 
      <f:convertNumber type="currency" currencySymbol="€"/> 
     </h:outputText> 
    </p:column> 

    <p:column styleClass="totaleRowColor" style="text-align: right;" width="60"> 
     <h:outputText value="#{storicoSoggettoProdottoBean.utilizzatoSoggettoSum}"> 
      <f:convertNumber type="currency" currencySymbol="€"/> 
     </h:outputText> 
    </p:column> 

    <p:column styleClass="totaleRowColor" style="text-align: right;" width="60"> 
     <h:outputText value="#{storicoSoggettoProdottoBean.sconfinoSoggettoSum}"> 
      <f:convertNumber type="currency" currencySymbol="€"/> 
     </h:outputText> 
    </p:column> 

    <p:column styleClass="totaleRowColor" style="text-align: right;" width="60"> 
     <h:outputText value="#{storicoSoggettoProdottoBean.inPropostaSoggettoSum}"> 
      <f:convertNumber type="currency" currencySymbol="€"/> 
     </h:outputText> 
    </p:column> 

    <p:column styleClass="totaleRowColor" style="text-align: right;" width="60"> 
     <h:outputText value="#{storicoSoggettoProdottoBean.garanzieBancarieSoggettoSum}"> 
      <f:convertNumber type="currency" currencySymbol="€"/> 
     </h:outputText> 
    </p:column> 

    <p:column styleClass="totaleRowColor" width="87" /> 

    <p:column styleClass="totaleRowColor" style="text-align: right;" width="60"> 
     <h:outputText value="#{storicoSoggettoProdottoBean.rischioIndirettoVsTerziSoggettoSum}"> 
      <f:convertNumber type="currency" currencySymbol="€"/> 
     </h:outputText> 
    </p:column> 

    <p:column styleClass="totaleRowColor" style="text-align: right;" width="60"> 
     <h:outputText value="#{storicoSoggettoProdottoBean.rischioPonderatoSoggettoSum}"> 
      <f:convertNumber type="currency" currencySymbol="€"/> 
     </h:outputText> 
    </p:column> 

    <p:column styleClass="totaleRowColor" width="25" /> 
</p:summaryRow> 

ответ

1

Не уверен, что если атрибут Объединение столбцов столбца требуется для ожидаемого результата ...?

Проверьте витрину Primefaces для образца, если вы не знаете: http://www.primefaces.org/showcase/ui/data/datatable/summaryRow.xhtml

+2

Привет! Спасибо, что ответили. Фактически, я нашел проблему. Я думал, что я могу использовать компонент SummaryRow в Primefaces для размещения строки «Total», но сводная строка работает по-другому. Сводная строка будет вставлять новую строку каждый раз при изменении значения. –

+0

Я предлагаю вам дать ответ другим пользователям в будущем: – chaeschuechli

+0

Привет, Пауло, как вы решили проблему. У меня такая же проблема. Можете ли вы поделиться образцом кода? –

1

Как отмечалось в this question, вы должны указать атрибут SortBy на р: DataTable тег для резюме строки для работы (как вы сделали в своем фрагменте кода). Primefaces использует выражение в теге sortBy для группировки записей таблицы, а затем предоставляет сводную строку для каждой группы.

Чтобы получить только одну группу, я попытался это: штраф

<p:dataTable sortBy="#{1}" ...> 

работает для меня, я получаю только одну итоговую строку с моим итога в настоящее время.

 Смежные вопросы

  • Нет связанных вопросов^_^