Criteria for selecting only a matching set of records from a DataSource. Criteria can be applied on the client and server. Unless configured otherwise, criteria will generally be applied client-side by ResultSets via ResultSet.applyFilter().
Client- and server-side systems built into SmartClient understand two criteria formats by default: simple key-value pairs (Criteria) or the AdvancedCriteria format.
Simple key-value Criteria are represented via a JavaScript Object where each property specifies the name and required value for a field. Multiple legal values for a field can be provided as an Array. For example:
var criteria = { field1 : "value1", field2 : ["value2", "value3"] }
Would select all records where field1 has value "value1" and where field2 has either "value2" or "value3". When writing custom client and server-side filtering logic, criteria must be a JavaScript Object but the properties of that Object can contain whatever data you want. WhenAdvancedCriteria is a format for representing search criteria which may include operators on field values such as "less than", or may include sub-clauses such as several criteria applied to fields joined by an "OR" operator.
SmartClient DataSources can use AdvancedCriteria to search a list of Records, and the SmartClient Java Server can translate AdvancedCriteria to either SQL or Hibernate queries (Note: The server-side AdvancedCriteria handling feature is only available with the Power and Enterprise Editions of SmartClient; the Pro Edition is limited to ordinary criteria handling on the server side).鍙儨Power鐗堝拰Enterprise鐗堥兘鑰佽吹鑰佽吹鐨勶紝浼佷笟鐗堢殑閮芥湁鎸塁PU鍗栫殑浜嗭紝鏅曞掋?/span>
If the entire dataset is cached locally, SmartClient can perform AdvancedCriteria filtering on the client, avoiding a server call.
An AdvancedCriteria is an ordinary JavaScript object which can be created directly with JavaScript literal notation. For example:
An AdvancedCriteria is in effect a Criterion that has been marked with _constructor:"AdvancedCriteria" to mark it as complete criteria.var advancedCriteria = {
_constructor:"AdvancedCriteria",
operator:"and",
criteria:[
// this is a Criterion
{ fieldName:"salary", operator:"lessThan", value:"80000" },
{ operator:"or", criteria:[
{ fieldName:"title", operator:"iContains", value:"Manager" },
{ fieldName:"reports", operator:"notNull" }
]
}
]
}