Our state of the art Gantt chart


Post by quandarycg »

Looking through the docs, it is very clear that in the task edit menu if you set the name to the actual name of the field, it will render the value automatically. This is what I am referring to :

 newTabField : {
                            type   : 'textfield',
                            weight : 710,
                            label  : 'New field in New Tab',
                            // Name of the field matches data field name, so value is loaded/saved automatically.
                            // In this case it is equal to the Task "name" field.
                            name   : 'name'
                        }

My question is: How can I grab the value for a tab field of type 'Button'?

I tried setting the same name, but only static 'name' comes back, not the actual field value: name.

My goal is to pass a url to this button to redirect users back to the task in our external system.


Post by Animal »

The values from the fields of a record are distributed into child widgets in the editor where the name of the widget matches the name of the field. But the widget has to have a value property - it sets the value.

A Button doesn't have a value property.

I think we can fix this with a small augmentation of the Container class.

It has this config: https://www.bryntum.com/docs/gantt/api/Core/widget/Widget#config-defaultBindProperty

The setting of record values into child widgets should really use this property. It defaults to value, but it should use the name specified by that property. When we fix this, your button could set it to the nae of some other config.

https://github.com/bryntum/support/issues/4072


Post by quandarycg »

So this fix should make the button component will behave and pull name data as the text field would?


Post by mats »

Yes, you will be able to specify which property on the Button should receive a data value from the data record.


Post by quandarycg »

Where does this get specified? i.e an example of how I would go about specifying this in the model

If there is documentation on this, I can review off of that. I just was not able to find anything on this case.


Post by mats »

Docs aren't yet updated (ticket is in review stage). Old docs: https://bryntum.com/docs/scheduler/api/Core/widget/Widget#config-defaultBindProperty

For your button in a Container, you'd set:

new Button({
     defaultBindProperty : 'text'
});

Post by quandarycg »

So here after applying it still does not operate as intended. I used a textField to ensure the field has a value and it does prove correct.

 ReturnButton: { // this one still does not dynamically load the value from 'returnToQB'
                                            type: 'button',
                                            defaultBindProperty : 'textfield',
                                            flex: '1 0 50%',
                                            // text: 'returnToQB',
                                            weight: 710,
                                            htmlEncode: false,
                                            value: 'returnToQB',
                                            // Name of the field matches data field name, so value is loaded/saved automatically
                                            name: 'returnToQB',
                                            // text: 'returnToQB',
                                            // href: 'returnToQB'
                                            onClick: function (value) { alert(value) }
                                        },
 testButtonURLField: {  // this one does dynamically load the value from 'returnToQB'
                                            type: 'textfield',
                                            weight: 710,
                                            label: 'TEST',
                                            // Name of the field matches data field name, so value is loaded/saved automatically
                                            name: 'returnToQB',
},

Post by mats »

Please note the ticket is not yet resolved, you can see above its state is "Ready for review". Once it says Resolved you can grab it from the nightly build to try it out.


Post by quandarycg »

Okay thank you so much!


Post by quandarycg »

So when I pull the new version. Here is my new button object:

taskEdit: {
                            items: {
                                generalTab: {
                                    items: {
                                        returnField: { // does not work
                                            type: 'button',
                                            defaultBindProperty: 'text',
                                            flex: '1 0 50%',
                                            weight: 710,
                                            htmlEncode: false,
                                            // Name of the field matches data field name, so value is loaded/saved automatically
                                            name: 'returnToQB',
                                            onClick: function (value) { console.log(value) }
                                        },
                                        testButtonURLField: { // works
                                            type: 'textfield',
                                            weight: 710,
                                            label: 'TEST',
                                            // Name of the field matches data field name, so value is loaded/saved automatically
                                            name: 'returnToQB',
                                        },
                                     

The button still does not have a dynamic name, yet the text field below it has the value and works. Any suggestions?


Post Reply