ExtJS 4,自定义Ext.grid.Panel的布尔列值

Dfr*_*Dfr 4 javascript extjs extjs4

美好的一天,我有一个布尔列的网格:

 var grid = Ext.create('Ext.grid.Panel', {
      ...
      columns: [{
           dataIndex: 'visibleForUser',
           text: 'Visible',
           editor: {
              xtype: 'checkboxfield',
              inputValue: 1 // <-- this option has no effect
           }
      },
      ...
Run Code Online (Sandbox Code Playgroud)

Grid的商店通过JSON代理远程存储.当我保存或更新行时,生成的JSON看起来像:

{... visibleForUser: false, ... }
Run Code Online (Sandbox Code Playgroud)

正如你看到的,ExtJS的序列化复选框值truefalseJSON条款.我需要自定义这个并序列化,比方说,1以及0任何建议如何实现这一目标?谢谢.

Izh*_*aki 5

我刚刚在系统范围内更改了我的复选框,以便始终执行/响应01:

Ext.onReady(function(){
    // Set the values of checkboxes to 1 (true) or 0 (false), 
    // so they work with json and SQL's BOOL field type
    Ext.override(Ext.form.field.Checkbox, { 
        inputValue: '1',
        uncheckedValue: '0'
    });
});
Run Code Online (Sandbox Code Playgroud)

但你可以在每个复选框中添加此配置.