I am using grails 2.4.2. I need to create a list based on like keyword of query. Suppose this is an example >>
def results = c.list(max: iDisplayLength, offset: iDisplayStart) {
and {
// eq("activeStatus", ActiveStatus.ACTIVE)
}
if (sSearch) {
or {
ilike('title', sSearch)
ilike('shortDesc', sSearch)
}
}
}
Here, I can search by field with sSearch params. But suppose in this domain I have a parent domain instance named Parent parent. Now if I also want to check the value of parent.typeName with sSearch, then how should I do this. I have tried as follows >>
or {
ilike('title', sSearch)
ilike('shortDesc', sSearch)
ilike('parent.typeName', sSearch)
}
But it gives error. Actually I want to do this for datatable. To keep the parent class field under search option. Is there any way to do this with parent class object? Can you guys please help ?
My Domain Audio Domain >>
package streaming
class Audio {
static mapping = {
table('audio')
version(false)
}
String title
// StreamType streamType
String shortDesc
String filePath
String imagePath
String imageName
int downloadCount
boolean isActive
static belongsTo = [streamType: StreamType]
static constraints = {
title(nullable: false, blank: false,unique: true)
shortDesc(nullable: false, blank: false)
filePath(nullable: false, maxSize: 2000)
imagePath(nullable: false, maxSize: 2000)
imageName(nullable: false)
downloadCount(nullable: true)
}
String toString(){
return title
}
}
StreamType domain >>
package streaming
class StreamType {
static mapping = {
table('stream_type')
version(false)
}
String typeName
static hasMany = [audio: Audio, video: Video]
static constraints = {
typeName(nullable: false, blank: false)
}
String toString(){
return typeName
}
}
You can access
StreamType
domain properties by placing them instreamType
closure or byalias
.By closure-
By alias -