0

Is there is an easy way to define unchecked value for a checkbox in ExtJS 6.7 modern toolkit? Like Ext.form.field.Checkbox.uncheckedValue in classic toolkit.

At the first glance I should override Ext.form.field.Checkbox or use Ext.data.writer.Writer.transform in modern and it seems like overkill for me.

Sergey Novikov
  • 4,096
  • 7
  • 33
  • 59

1 Answers1

1

In modern toolkit - there isn't uncheckedValue in checkboxfield.

I guess you're using record.set(form.getValues()); and next store.sync() so you can do what you said (override checkbox or use Ext.data.writer.Writer.transform) or you can use serialize in model.

A function which converts the Model's value for this Field into a form which can be used by whatever Ext.data.writer.Writer is being used to sync data with the server.

Example:

 Ext.define('App.model.Test', {
      fields: [{ 
           name: 'status', 
           type: 'auto',
           serialize: function (value, record) {
                if(value === 1){
                     return "success";
                } else {
                     return "failed";
                }
           }
      }]
 });
norbeq
  • 2,923
  • 1
  • 16
  • 20