Our blazing fast Grid component built with pure JavaScript


Post by Landpoint »

What listener(s) should I use on a check column?
The documentation says you can have a listener on the columns, but I could not find the list of raised events.
My Code thus far:
    {
                    type:'check',
                    text:'',
                    field:'showInGrid',
                    htmlEncode:false,
                    filterable:false,
                    searchable:false,
                    listeners:{
                        click:()=>{console.log('hi');} 
                    }

Post by pmiklashevich »

Event is called "toggle". Docs here: https://www.bryntum.com/docs/scheduler/ ... ent-toggle
Could you please point me out to the place where you saw that "The documentation says you can have a listener on the columns, but I could not find the list of raised events."? I'll update that place.

Pavlo Miklashevych
Sr. Frontend Developer


Post by Landpoint »

Hi Pavel:

Here is the page I found the basic information on:
https://www.bryntum.com/docs/grid/#Grid ... heckColumn

Post by Landpoint »

Ha,
I swear that information wasn't there yesterday LOL

Post by Landpoint »

So, the toggle event does not seem to be firing
Here is my full class:
    class EmployeeGrid extends Grid { 
        static get defaultConfig() {
            return {
                features: {
                    filterBar: true,
                    cellEdit: true,
                    contextMenu:false
                },

                rowHeight: 48,

                columns: [{
                    text: '', 
                    field: 'name',
                    htmlEncode: false,
                    cellCls: 'b-equipment',
                    renderer: (data) => `<img height="32px" src="${data.record.image}" class="img-circle" alt="">${data.record.name}`
                },
                {
                    type:'check',
                    text:'',
                    field:'showInGrid',
                    htmlEncode:false,
                    filterable:false,
                    searchable:false,
                    listeners:{
                        toggle:()=>{console.log('hi');} 
                    }

                }
            ]
            };
        }
    }

Post by pmiklashevich »

That's a bug! Thanks for the report! "listeners" config doesn't work for columns. I've created a ticket to get it fixed: https://app.assembla.com/spaces/bryntum/tickets/7628
As a temporary workaround I can suggest you to add listeners after its creating:
scheduler.columns.get('showInGrid').on({toggle : () => console.log('hi')})

Pavlo Miklashevych
Sr. Frontend Developer


Post by Landpoint »

That seems to be a workaround I can use!
Thanks

Post by Landpoint »

I suppose when you look into this, you may want to also consider this.
The state of the variable which I am binding to, is not getting changed until after the toggle event is fired.
I am using this as an event to reload data on the grid, and toggle is happening before it sets the new data change, and thus my scheduler does not reflect the right data.

Post by Landpoint »

In my version of your code, I changed the order of execution in the onCheckboxChange function on CheckColumn class, so the variable changes first, it works as it should in my case, you may consider making the same update to the core code too

Post by pmiklashevich »

Thanks for the feedback! We've decided to provide "beforeToggle" and fire "toggle" after data is set to the record. Ticket here: https://app.assembla.com/spaces/bryntum/tickets/7632

Pavlo Miklashevych
Sr. Frontend Developer


Post Reply