Datatable setColumnWidth problem

Hi there,
I am trying to set the width of a column in a datatable after initialization (actually when the window is resized by using the resize event).

var datatable = new webix.ui({
        view: "datatable",
...
        onAfterRender: webix.once(function () {
                webix.event(window, "resize", function () {
                    datatable.define("width", getAvailableResultListWidth());
                    datatable.setColumnWidth(1, 100);
...
});

But when i do that i get an exception:

Uncaught TypeError: Cannot read property 'minWidth' of undefined(…)
_setColumnWidth @ webix_debug.self-2acaddd….js?body=1:19062
setColumnWidth @ webix_debug.self-2acaddd….js?body=1:19056
(anonymous function) @ fast.results.self-5489454….js?body=1:187
(anonymous function) @ webix_debug.self-2acaddd….js?body=1:244

minWidth is set on the table and i tried setting minWidth on the column (or on all columns), but it does not help.
What am i doing wrong?

i am using webix 4.0.16.

Regards,
Marc

Hi,

As far as I can see, your code works:

http://webix.com/snippet/d226c012

Can you please provide a snippet that will represent the issue?

Hi Listopad,

I don’t use fillspace, but fixed values as the data i have in the table is loaded dynamically through ajax calls. And fillspace seemed to slow down the scrolling while its retrieving new data.

I managed to reproduce the issue like this:
http://webix.com/snippet/90188bb5
Resize the browser and you get a script error.
In my realworld setup the width of all columns matches up to the available width of the table, but the error still exists.

Regards, Marc

Hi,

In the snippet, you are trying to set the width to non-existent column

datatable.setColumnWidth(1, 100); 
// assumes that there's a column with id:1

while columns are

columns:[ 
    { id:"status", width:300 },
    { id:"name", width:100 } 
]

Please check the corrected sample:

http://webix.com/snippet/7ed2d888

Oh, that an obvious fix. :wink: probably i thought i need the index of the column there and not the name. Thanks for the hint!