2013-06-02 21 views
1

在我的分貝我有值0和1(假,真)列ACTIFGridBooleanColumn數據首先由0和1,但沒有真假

我試圖用一列。布爾與我的數據庫值0和1 ...但它不起作用。

{ 
    xtype: 'booleancolumn', 
    dataIndex: 'Actif', 
    text: 'MyBooleanColumn', 
    falseText: 'Non', 
    trueText: 'Oui' 
} 

請幫我:)

我的模型

Ext.define('ModuleGestion.model.UtilisateursApplicatifs', { 
extend: 'Ext.data.Model', 

fields: [ 
    { 
     name: 'Nom' 
    }, 
    { 
     name: 'Prenom' 
    }, 
    { 
     name: 'Identification' 
    }, 
    { 
     name: 'MotDePasse' 
    }, 
    { 
     name: 'IUtilisateurApplicatif' 
    }, 
    { 
     name: 'FonctionRepertoire' 
    }, 
    { 
     name: 'FonctionAnimation' 
    }, 
    { 
     name: 'FonctionFormation' 
    }, 
    { 
     name: 'FonctionAdministration' 
    }, 
    { 
     name: 'Actif' 
    } 
]}); 

解決的辦法是刪除該值的回報的雙引號:

$resultat = json_encode($resultat); 
$resultat = str_replace('"Actif":"0"', '"Actif":0', $resultat); 
$resultat = str_replace('"Actif":"1"', '"Actif":1', $resultat); 
+0

你是什麼意思 「它不工作」? –

+0

當他讀取顯示值不匹配的值0 = false和1 = true但仍然爲真 – VincentDA

+0

編輯您的帖子以顯示您的模型定義,問題可能在那裏。 –

回答

0

我有類似的情況和工作與0和1從數據庫我使用非布爾co lumn。從數據庫我發送0和1,在我的列渲染器我檢查這一點,並進行一些轉換。檢查我的示例(這裏是actioncolumn - 它是針對單元格中的顯示圖標)。這是決定你的情況的一種方法。 我的看法:

xtype: 'actioncolumn', 
width: 55, 
align: 'center', 
dataIndex: 'Actif', 
menuDisabled: 'true' 
text: '', 
sortable: false, 
fixed: 'true', 
renderer: function (value, metadata, record) { 
    if (value == '0') { 
     //some code 
    } 
    else { 
     //some code 
    } 
}, 
getTip: function (value, metadata, record) { 
    if (value == '0') { 
     return 'here 0'; 
    } else { 
     return 'here 1'; 
    } 
} 

您不需要更改型號。

在你的例子中,我認爲你應該在模型中添加你的字段類型。

here's example

{ name: 'Actif', type: 'boolean' } 
+0

好thx但0和1 ...渲染總是trueText(與booleancolum)然後我supose是與其他類似列 – VincentDA

+0

檢查您的服務器端,願你永遠真實!?你可以不用布爾值來工作,0和1應該可以工作。 –

+0

它適用於:$ resultat = json_encode($ resultat); $ resultat = str_replace('「Actif」:「0」','「Actif」:0',$ resultat); $ resultat = str_replace('「Actif」:「1」','「Actif」:1',$ resultat); – VincentDA

相關問題