Column.setFilterBy()和Column.setSortBy()我应该给出什么类型的参数? [英] Column.setFilterBy() and Column.setSortBy() what type of parameter should i give?

查看:97
本文介绍了Column.setFilterBy()和Column.setSortBy()我应该给出什么类型的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从托管bean动态地设置我的datatable列的过滤和排序,但是我有一个关于我应该给这些方法的值的问题,这里是我尝试的代码: p>

i'm trying to set the filtering and sorting for a column of my datatable dynamically from a managed bean, but i had a problem regarding the value that i should give to those methods, here is the code i tried :

  /*this is the XHTML that i try to do in Java code :
    <p:column style="text-align:center;"
     width="10"
     id="etatCol"
     filterBy="#{exam.examen.studyPatientState}"
     filterOptions="#{examenListBean.etatExamOptions}"  
     filterMatchMode="exact"
     headerText="Etat"
     filterStyle="dispo"
     sortBy="#{exam.examen.studyPatientState}" 
     rendered="true"> 

     <p:graphicImage value="/images/study_State_icons/#{exam.examen.studyPatientState}.png"/>
     </p:column>
    */

    //Patstate
    Column patSate = (Column) application.createComponent(Column.COMPONENT_TYPE);
    patSate.setHeaderText("Etat");
    patSate.setWidth("10");
    patSate.setId("etatCol");
    patSate.setFilterBy("#{exam.examen.studyPatientState}");
    patSate.setFilterOptions(etatExamOptions);
    patSate.setFilterMatchMode("exact");
    patSate.setFilterStyle("dispo");
    patSate.setSortBy("#{exam.examen.studyPatientState}");
    patSate.setRendered(true);

    GraphicImage patsategraph = (GraphicImage) application.createComponent(GraphicImage.COMPONENT_TYPE);
    ValueExpression patsategraphExp = ef.createValueExpression(elc, "/images/study_State_icons/#{exam.examen.studyPatientState}.png", Object.class);
    patsategraph.setValueExpression("value", patsategraphExp);
    patSate.getChildren().add(patsategraph);
    table.getChildren().add(patSate);

除了列过滤器之外,所有内容都很好地显示,它不会显示我提供的选项列表:

everything is rendered well except the column filter,it won't show a list of options that i provide :

etatExamOptions = createFilterOptions();

private SelectItem[] createFilterOptions() {

    SelectItem[] options = new SelectItem[10];

    options[0] = new SelectItem("", "X0");
    options[1] = new SelectItem(0, "X1");
    options[2] = new SelectItem(1, "X2");
    options[3] = new SelectItem(2, "X3");
    options[4] = new SelectItem(3, "X4");
    options[5] = new SelectItem(4, "X5");
    options[6] = new SelectItem(5, "X6");
    options[7] = new SelectItem(6, "X7");
    options[8] = new SelectItem(7, "X8");
    options[9] = new SelectItem(8, "X9");

    return options;
}


推荐答案

您的XHTML示例无效:

Your XHTML example is invalid:

<p:column 
  filterBy="#{exam.examen.studyPatientState}"
  sortBy="#{exam.examen.studyPatientState}" 
> 

filterBy 必须代表唯一的属性名称。这同样适用于 sortBy

这是有效的XHTML:

This is valid XHTML:

<p:column 
  filterBy="studyPatientState"
  sortBy="studyPatientState" 
> 

只需在Java代码中执行相同的操作:

Just do the same in Java code:

patSate.setFilterBy("studyPatientState");
patSate.setSortBy("studyPatientState");

将来,尝试首先获取XHTML的工作和有效性,然后将XHTML转换为Java码。 没有不能在XHTML中完成,但只能在Java中。

In the future, try to get the XHTML working and valid first, then translate exactly that XHTML to Java code. There's nothing which can't be done in XHTML but only in Java.

这篇关于Column.setFilterBy()和Column.setSortBy()我应该给出什么类型的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆