介面 yii\data\DataProviderInterface
DataProviderInterface 是資料提供者類別必須實作的介面。
資料提供者是元件,用於排序和分頁資料,並將其提供給諸如 yii\grid\GridView、yii\widgets\ListView 等小工具。
關於 DataProviderInterface 的更多詳細資訊和使用方法,請參閱關於資料提供者的指南文章。
公開方法
方法 | 描述 | 定義於 |
---|---|---|
getCount() | 傳回目前頁面中的資料模型數量。 | yii\data\DataProviderInterface |
getKeys() | 傳回與資料模型相關聯的鍵值。 | yii\data\DataProviderInterface |
getModels() | 傳回目前頁面中的資料模型。 | yii\data\DataProviderInterface |
getPagination() | yii\data\DataProviderInterface | |
getSort() | yii\data\DataProviderInterface | |
getTotalCount() | 傳回資料模型的總數。 | yii\data\DataProviderInterface |
prepare() | 準備資料模型和鍵值。 | yii\data\DataProviderInterface |
方法詳情
傳回目前頁面中的資料模型數量。
這等同於 count($provider->getModels())
。當 pagination 為 false 時,這與 totalCount 相同。
public abstract integer getCount ( ) | ||
return | integer |
當前頁面的資料模型數量。 |
---|
public function getCount();
傳回與資料模型相關聯的鍵值。
public abstract array getKeys ( ) | ||
return | 陣列 |
對應於 models 的鍵值列表。models 中的每個資料模型都由此陣列中對應的鍵值唯一識別。 |
---|
public function getKeys();
傳回目前頁面中的資料模型。
public abstract array getModels ( ) | ||
return | 陣列 |
當前頁面的資料模型列表。 |
---|
public function getModels();
public abstract yii\data\Pagination|false getPagination ( ) | ||
return | yii\data\Pagination|false |
分頁物件。如果這是 false,則表示分頁已停用。 |
---|
public function getPagination();
public abstract yii\data\Sort|false getSort ( ) | ||
return | yii\data\Sort|false |
排序物件。如果這是 false,則表示排序已停用。 |
---|
public function getSort();
傳回資料模型的總數。
當 pagination 為 false 時,這與 count 相同。
public abstract integer getTotalCount ( ) | ||
return | integer |
可能的資料模型總數。 |
---|
public function getTotalCount();
準備資料模型和鍵值。
此方法將準備可透過 getModels() 和 getKeys() 檢索的資料模型和鍵。
如果之前未呼叫過此方法,則會由 getModels() 和 getKeys() 隱式呼叫。
public abstract void prepare ( $forcePrepare = false ) | ||
$forcePrepare | 布林值 |
即使之前已完成,是否強制執行資料準備。 |
public function prepare($forcePrepare = false);
註冊 或 登入 以發表評論。