隨筆 - 6, 文章 - 1, 評論 - 13, 引用 - 0
          數據加載中……

          SmartClient中Criteria 和 AdvancedCriteria的理解

          時間不早了,就少寫一些了。

          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. When
           sent to the SmartClient server, the Java representation of the criteria is described here. When sent to other servers, the operationBinding.dataProtocol affects the format.

          格式相當簡單。注意前面字段field1,是不需要將引號的.

          AdvancedCriteria 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版都老貴老貴的,企業版的都有按CPU賣的了,暈倒。

          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:

          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" }
          ]
          }
          ]
          }
          An AdvancedCriteria is in effect a Criterion that has been marked with _constructor:"AdvancedCriteria" to mark it as complete criteria.

          posted on 2011-10-24 23:08 風清揚 閱讀(387) 評論(0)  編輯  收藏 所屬分類: SmartClient


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 明水县| 醴陵市| 宁陵县| 增城市| 新晃| 凤冈县| 沿河| 安远县| 临高县| 宣化县| 淮北市| 桓台县| 琼海市| 云龙县| 永川市| 瑞丽市| 广州市| 日照市| 海伦市| 通榆县| 拉孜县| 丹棱县| 进贤县| 洪洞县| 积石山| 获嘉县| 方山县| 九龙县| 香河县| 赤壁市| 建昌县| 琼海市| 元谋县| 张北县| 滕州市| 黄冈市| 潢川县| 涟源市| 郑州市| 阳东县| 普定县|