Our blazing fast Grid component built with pure JavaScript


Post by awacode »

Dear Bryntum team,

how can i achieve dynamic column configuration?

My customers application is a vue application and i need to display some database tables based on user selection. So i have a form, where the user can select the table name of the table he want to display and based on the selection bryntum grid is used to display the table underneath.

As the table names change reactively also the column configuration needs to change reactively as each database table looks different.

I got this warning from bryntum:

BryntumGridComponent development warning!
"columns" is a static config option for component constructor only. No runtime changes are supported!

How would you recomment to achieve this use case with vue and reactive table data (rows & columns)

Best regards


Post by mats »

It should work, just a minor tweak needed from our side (will be fixed in next release). Until then try changing to doing:

grid.columns.data = [{ text : 'foo' }]

Post by awacode »

at the moment i am using property binding as shown in the documentation

<bryntum-grid
v-if="gridConfig"
ref="grid"
v-bind="gridConfig"
:readOnly="readonly"
/>

the gridConfig is reactive and as soon as its values (column & data) change the binding gets updated with the new data. That leads to the mentioned warning.

So you mean i need to change the implementation, not to use prop binding but to use javascript assignment as you posted.. until the next release and then go back to property binding?
Is it only a warning or does it lead to functional problems? if it's only the warning but the grid is updating accordingly then i would wait for your fix instead of changing the implementation for a temporarily time. If it blocks functionality i need to go this way :-(


Post by marcio »

Hey awacode,

We recommend changing to the approach that Mats suggested, mostly because we cannot guarantee that all the functionalities will work as expected.

We had cases where there was no behavior change, even with the warnings, but also had cases where that led to unexpected behavior.

Best regards,
Márcio


Post by awacode »

but that mean never to set gridConfig over the prop, right? but aren't the props required for the bryntum grid component?

Do you have an example of VUE 3 Usage not setting the columns & data over props but the other way?


Post by marcio »

Instead of changing the gridConfig object, you can change it using the grid ref.

this.$refs.grid.instance.value.columns.data = // new value

Best regards,
Márcio


Post by awacode »

i managed to get

this.$refs.grid.instance.value.columns.data = // new value

running. What is the equivalent to replace store data?


Post by awacode »

i tried

this.$refs.grid.instance.value.store.removeAll();
 this.$refs.grid.instance.value.store.add(rows);

but then i get this error on console:

Attachments
Bildschirmfoto 2024-02-09 um 14.20.49.png
Bildschirmfoto 2024-02-09 um 14.20.49.png (172.61 KiB) Viewed 143 times

Post by mats »

No need to removeAll first.

Like so:

this.$refs.grid.instance.value.store.data = // new value

Post by awacode »

When doing it that way, i get the correct number of rows, but they are empty:

Attachments
Bildschirmfoto 2024-02-09 um 14.39.07.png
Bildschirmfoto 2024-02-09 um 14.39.07.png (353.25 KiB) Viewed 137 times

Post Reply