Datatable Server Side Data Load unexpected behavior while trying to use scrollTo

Hi
I have a problem with the scrollTo function in datatable.
I would like to save the actual scrolling position, clear data, refresh the datatable and then go back to the scroll position.

I have tried it with:

var state = $$(‘datatable1’).getScrollState();

var state1 = $$(“datatable1”).getState();

$$(“datatable1”).clearAll();
$$(“datatable1”).load($$(“datatable1”).config.url);

if (state1)
{
$$(“datatable1”).setState(state1);
}

$$(“datatable1”).scrollTo(state.x, state.y);

or

webix.delay($$(‘datatable1’).scrollTo, $$(‘datatable1’), [state.x, state.y]);

But the scroll state only changes the x axis. The y axis will not scroll to the
value state.y. y axis remains 0.

I have also tried to use something like this. But it doesn’t work.
$$(“datatable1”).showItemByIndex(10) ;
It stays at position 0.

Could you give me a hint?

And a second question.
Is it possible to set a predefined serverside column text filtervalue when the page is loading? Search for “abced” in column “cpualarm_projektinfo”
{ id:“cpualarm_projektinfo”, header:[“CPU”, {content:“serverFilter”}], sort:“server”, minWidth :100, maxWidth :400, adjust:“data” },

Thank you.

Regards
Andreas

datatable.load is async method.
all postloading procedure should be done in then handler or optional callback
https://docs.webix.com/api__link__ui.datatable_load.html

var state = $$('datatable1').getScrollState();

var state1 = $$("datatable1").getState();

$$("datatable1").clearAll();
$$("datatable1").load($$("datatable1").config.url).then(function(){
    if (state1)
    {
        $$("datatable1").setState(state1);
    }
    $$("datatable1").scrollTo(state.x, state.y);
});

Hello

Thank you for your answer.
But that doesn’t solve the problem completely.

I think it’s because:
When i load the data after the clear all command,
datatable loads the data from the server without the server filter active.

Then, the setState() command loads data a second time automatic from server with filter active.

I think the scrollTo command is now executed after the first load command.
And then the setState() command sets the scroll position back to 0

How can I execute the scrollTo command after the from setState() automatic executed load command?

Thank you.

Regards
Andreas

if you have filters then use filterByAll instead.
https://docs.webix.com/api__ui.datatable_filterbyall.html
to set scroll state use onBeforeFilter / onAfterFilter events
https://snippet.webix.com/ll16b1oc

That works.

Thank you very much.

Hello
I have another problem with the async server side loading.

I have datatable with server side loading and server side filtering.
Normally, it works perfect. But when i change a value of a record, and then filter this column with the changed value to any value, webix message prints data loading error.
If I set the filter to a new value after that, it works again.

Here is the Console output.
Data Updated:
Object { cpualarm_projektinfo: “Alarmserver”, nAlmId: “19”, nTagsId: “123”

On Before Load Count 2805

This is the query to the serverside after filtering.
Datatable Url Load
Object { start: 0, count: 50, continue: “true”, filter: {…}, code: “”, sql: “”, values: [] }

And here comes the answer from the server side.
Datatable Url Load Then
Object { data: (50) […], pos: 0, total_count: 508 }

On Before Load Count 0
On After Load Count 0
Data loading error webix.js:49298:16
Object:
Object { “$ready”: (5) […], config: {…}, _settings: {…}, _evs_events: {…}, _evs_handlers: {…}, _evs_map: {}, _destructor_handler: {…}, _parent_cell: {…}, “$scope”: null, _viewobj: div#datatable1578250969096.webix_view.webix_dtable.smallerHeader.webix_dtable_focused
, … }
webix.js:49299:16

Response: [EMPTY DATA] webix.js:49300:16
On After Load 0

Here’s my datatable url script:

url:
{
$proxy:true,
load:function(view, params)
{
	console.log("Datatable Url Load", obj1);	

	var promise = webix.ajax("alarm_editor_data.php", obj1);
					
	promise.then(function(realdata)
	{
	console.log("Datatable Url Load Then", realdata.json());
						
	})

	return promise;
}

Could you give me a hint, why datatable displays the error message, although the data are sent from the server.

Thank you.