Premium support for our pure JavaScript UI components


Post by durban »

Hi.
I want to know how to make a field required and does not have an empty value.

I have tries "required:true" on field, I have tried "nullable:false", I have also tried :

this.gridObj.on('cancelCellEdit',(args) => {
        if(args.source.selectedRecord.data.rowcode === "" || !args.source.selectedRecord.data.rowcode) {
          return false;
        }
      })
      
this.gridObj.on('beforeFinishCellEdit',(args) => { if(args.source.selectedRecord.data.rowcode === "" || !args.source.selectedRecord.data.rowcode) { return false; } })

But it does not work, when the user hits the "enter" button and the value of "rowcode" is empty it accepts it.

Thank you for helping


Post by alex.l »

Hi durban,

As I understood you are asking about CellEdit feature. https://bryntum.com/docs/grid/api/Grid/feature/CellEdit
There is https://bryntum.com/docs/grid/api/Core/widget/TextField#config-required property that you should pass to the editor https://bryntum.com/docs/grid/api/Grid/column/Column#config-editor

Here is example:

    columns : [
        { text : 'Name', field : 'name', flex : 1 },
        // ...
        { text : 'Team', field : 'team', flex : 1, editor : { required : true } },

Here is a demo that may be useful for you: https://bryntum.com/examples/grid/celledit/

All the best,
Alex


Post by durban »

Thank you for helping


Post Reply