【发布时间】:2011-06-10 20:52:56
【问题描述】:
编辑:搜索似乎以非常基本的方式工作,搜索在相关模型的所有字符串成员字段中输入的任何文本,没有特殊的搜索运算符。
如果有任何方法可以自定义搜索的工作方式,我想知道。现在看起来我只需要忽略内置的搜索内容并自己动手。
自从添加了 notes 字段后,它开始什么都不返回,而不是返回所有内容。
到目前为止唯一有效的方法是在搜索框中输入“test”,这将返回备注字段中带有“test”的记录。搜索“notes:test”或“notes=test”不起作用,也没有尝试搜索agent 或status 字段。我已经尝试过诸如“1400”之类的东西,这是我通过 phpMyAdmin 验证的值存在于代理字段中,以及状态字段中的“0”或“VALID”之类的东西,这是所有记录都有的。
模型字段:
public class AgentShift extends Model {
public enum Status { VALID, RESCHEDULED, EXTENDED, DELETED } // REDUCED?
@Required @Min(1000) @Max(99999)
public int agent;
public Status status = Status.VALID;
@Required
@Columns(columns={@Column(name="start_time"),@Column(name="end_time")})
@Type(type="org.joda.time.contrib.hibernate.PersistentInterval")
public Interval scheduled;
@Type(type="org.joda.time.contrib.hibernate.PersistentLocalTimeAsTime")
public LocalTime agent_in;
@Type(type="org.joda.time.contrib.hibernate.PersistentLocalTimeAsTime")
public LocalTime agent_out;
public String notes;
}
修改的crud列表页面:
#{extends 'main.html' /}
#{set title: 'Agent Shifts' /}
<div id="crudList" class="${type.name}">
<h2 id="crudListTitle">&{'crud.list.title', type.name}</h2>
<div id="crudListSearch">
#{crud.search /}
</div>
<div id="crudListTable">
#{crud.table fields:['id','agent','scheduled','status','notes'] }
#{crud.custom 'scheduled'}
#{if object.scheduled.getStart().toDateMidnight().equals(object.scheduled.getEnd().toDateMidnight())}
${org.joda.time.format.DateTimeFormat.forStyle("SS").printTo(out, object.scheduled.getStart())} to
${org.joda.time.format.DateTimeFormat.forStyle("-S").printTo(out, object.scheduled.getEnd())}
#{/if}
#{else}
${org.joda.time.format.DateTimeFormat.forStyle("SS").printTo(out, object.scheduled.getStart())} to
${org.joda.time.format.DateTimeFormat.forStyle("SS").printTo(out, object.scheduled.getEnd())}
#{/else}
#{/crud.custom}
*{
#{crud.custom 'entered_by'}
#{if object.entered_by}
${object.entered_by}
#{/if}
#{else} ?
#{/else}
#{/crud.custom}
#{crud.custom 'created'}
${org.joda.time.format.DateTimeFormat.forStyle("SS").printTo(out, object.created)}
#{/crud.custom}
}*
#{/crud.table}
</div>
<div id="crudListPagination">
#{crud.pagination /}
</div>
<p id="crudListAdd">
<a href="@{blank()}">&{'crud.add', type.modelName}</a>
</p>
</div>
【问题讨论】:
-
知道如何在任何成员字段中搜索文本吗?而不仅仅是字符串。现在有点卡在这个问题上。
标签: search playframework crud