Page 1 of 1

[REACT] How to set custom input field as requred in edit resources tab

Posted: Fri Mar 31, 2023 6:06 pm
by isadogan

Hi,

In edit task modal, resources tab; I want to set "Seviye" field as required.

Any way to do this?

Thanks


Re: [REACT] How to set custom input field as requred in edit resources tab

Posted: Fri Mar 31, 2023 6:59 pm
by marcio

Hey isadogan,

You can set the editor to use a field that is required like this

features : {
        taskEdit : {
            items : {
                // add custom Resources tab to the third position
                resourcesTab : {
                    title  : 'Resources',
                    items  : {
                        grid : {
                            columns : {
                                data : {
                                    seviye : {
                                        text   : 'Seviye',
                                        editor : { required : true }
                                    }
                                }
                            }
                        }
                    }
                }

Re: [REACT] How to set custom input field as requred in edit resources tab

Posted: Fri Mar 31, 2023 9:26 pm
by isadogan

Hi marcio,

Thank you for your response.

Actually, I've already tried this before posting this, but it didn't work :/

Here is an example by using your advanced demo:

features : {
        baselines : {
            disabled : true
        },
        dependencyEdit : true,
        filter         : true,
        labels         : {
            left : {
                field  : 'name',
                editor : {
                    type : 'textfield'
                }
            }
        },
        parentArea : {
            disabled : true
        },
        progressLine : {
            disabled   : true,
            statusDate : new Date(2019, 0, 25)
        },
        rollups : {
            disabled : true
        },
        rowReorder : {
            showGrip : true
        },
        timeRanges : {
            showCurrentTimeLine : true
        },
        fillHandle    : true,
        cellCopyPaste : true,
        taskCopyPaste : {
            allowNativeClipboard : true
        },
taskEdit: {
          items: {
            resourcesTab: {
              items: {
                grid: {
                  columns: {
                    data: {
                      titleLevel: {
                        text: "SEVÄ°YE",
                        field: "titleLevelId",
                        renderer: (props) => {
                          // display the name in the cell
                          const value = props.column.editor.store.data.find(
                            (item) => item.id === props.value
                          );
                          return value?.name;
                        },
                        editor: {
                          type: "combo",
                          valueField: "id",
                          displayField: "name",
                          required: true,
                          store: {
                            idField: "id",
                            data: [{id:1, name:"test 1"}, {id:2, name:"test 2"}],
                          },
                        },
                      },
                    },
                  },
                },
              },
            },
          },
        },
    },

Re: [REACT] How to set custom input field as requred in edit resources tab

Posted: Sun Apr 02, 2023 4:26 pm
by Animal

When you say "doesn't work"...

The field actually gets its required config set to true? You can interrogate the field to check that.

But you can still probably terminate the edit with the field in an "invalid" state. The next thing is how the cell editing should behave when its editor field is in an invalid state. That is through this: https://www.bryntum.com/products/grid/docs/api/Grid/column/Column#config-invalidAction