[技術:Ext/Js] Ext/Js 函式雜記

  • 4770
  • 0

1. ColumnModel 欄位如何調整寬度?
==> 設定每個 column 的 width, 並設定 forceFit=true, 即會自動調整寬度

2. formBind 屬性在 api 中找不到?
==> 描述於 FormPanel 的 monitorValid 屬性中, 如下:

 

這幾天開發的隨手記錄, 沒有整理的太好~

資料來源:
(1) Ext/Js 官網: http://www.extjs.com/
(2) 次世代 Ajax 解決方案 Ext/js 開發實戰
------------------------------------------------------------------------------------------------------

1. ColumnModel 欄位如何調整寬度?
==> 設定每個 column 的 width, 並設定 forceFit=true, 即會自動調整寬度

2.  formBind 屬性在 api 中找不到?
==> 描述於 FormPanel 的 monitorValid 屬性中, 如下:

monitorValid:Boolean

If true, the form monitors its valid state client-side and reqularly
fires the clientvalidation event passing the state.

When monitoring valid state, the FormPanel enables/disables any of its
configured buttons which have been configured with
 
formBind:true depending on whether the form is valid or not.

Defaults to false.

3. FormPanel getForm 函式:

getForm: Provides access to the Form which this panel contains.
getForm 參考資料: http://witcheryne.javaeye.com/blog/335577

getForm 會得到 BasicForm 物件, BasicForm.isValid() 用法為:
==> Return true if client-side validation on the form is successful.

4. REST 的參考資料:
http://zh.wikipedia.org/zh-tw/REST

5. Store 怎麼傳參數給後端?

Ans: (1) 當設定 RemoteSort:true 時, 使用 store.load() 時會自動將 sortInfo 作為參數傳給後台.
         (2) 另外 PageSize 屬性預設為 20, 作為後台排序時, 當作 start 與 limit 傳給後台.

6. Ext.Data.Store 筆記:
-----------------------------------------------------------------------------------------------
load(object options):Boolean

==> Loads the Record cache from the configured proxy using the configured reader.
==> 從 proxy 載入資料.

** Important: loading is asynchronous!
    This call will return before the new data has been loaded.
    To perform any post-processing where information from the load call is required,
    specify the callback function to be called, or use a 'load event handler'.

** If using remote paging, the first load call must specify the start and limit properties
    in the options.

   ==> 若使用 remote paging , 第一個 load call 需要在 options 中指定 start 與 limit 屬性.

** If using remote sorting, the configured sortInfo will be automatically included with the
    posted parameters according to the specified paramNames. 

paramNames: Object
------------------
An object containing properties which specify the names of the paging and sorting parameters
passed to remote servers when loading blocks of data.

==> 向遠端 Server 傳送分頁與排序參數的物件.

By default, this object takes the following form:
{
   start:'start' // The parameter name which specifies the start row.
   limit:'limit' // The parameter name which specifies number of rows to return.
   sort:'sort'   // The parameter name which specifies the column to sort on.
   dir:'dir'     // The parameter name which specifies the sort direction.
}           

If different parameter namnes are required,
this property can be overriden using a configuration property.

當設定 remoteSore:true 時,store 會在向後台請求資料時自動加入 sort 與 dir 兩個參數.
---------------------------------------------------------------------
options: Object
==> params:Object
==> callback:Function
==> scope:Object
==> add:Boolean

batch 屬性: Default to true. Multiple requests for each CRUD action will be combined and sent as one transaction.
                     將 CRUD Action 批次處理.

Ext.data.Store 事件

** load:(Store this, Ext.data.Record[] records, Object options)
==> Fires after a new set of Records has been loaded.
--> Listeners will be called with the following arguments.

this:Store
records:Ext.data.Record[]
--> The Records that were loaded.
options:Object
--> The loading options that were specified(see load for details).

** exception:(misc misc)
==> Fires if an exception occurs in the Proxy during a remote request.
    This event is relayed through the corresponding Ext.data.DataProxy.
    See Ext.data.DataProxy.exception for additional details.

parameters:
--> misc:misc
    --> see Ext.data.DataProxy.exception for description.

7. Json Reader 建構式:

JsonReader(object meta, Array/Object recordType)
==> Create a new JsonReader.

meta:Object
--> Metadata configuration options.

recordType:Array/Object
--> Either an Array of Field definition objects or
    a Record constructor created from Ext.data.Record.create.

8. Ext.util.Format

==> 將各種類型的資料轉換為特定格式字串.
==> 可呼叫其內部定義的常用工具函數來格式化資料.

函數分類:

(1) 操作字串

capitalize(String value): 將字串開頭的第一個字母變大寫.
ellipsis(String value, Number length): 截取第一個參數 value 前面指定的多個字元,
                                       並在後面附加 '...'.
htmlEncode(String value):
lowercase(String value):
stripScripts(Mixed value):
stripTags(Mixed value):
substr(String value, Number start, Number length):
trim(String value):

ex: Ext.util.Format.capitalize('name') ==> Name.

(2) 操作日期

date(Mixed value, [String format]):
dateRenderer(String format):

(3) 空值判斷

defaultValue(Mixed value, String defaultValue)
undef(Mixed value)

(4) 轉換數字
filesize(Number/String size)
usMoney(Number/String value)
 

 

黑貓仔的修練之路