phantomIdField for AjaxStore

Our blazing fast Grid component built with pure JavaScript
Post Reply
User avatar
proteams-kaan
Posts: 12
Joined: Fri Jan 04, 2019 1:22 pm

phantomIdField for AjaxStore

Post by proteams-kaan » Thu Jul 11, 2019 1:54 am

Hi,

While using the ajaxstore, for newly added items the store sets a string based phantomId but into the id field itself.

If we set the id field before the object is added to null, it causes an unhandled promise rejection after the response from the server is received.

Setting the ids to -1 seem to work without any issues.

I have two related questions:
1) Is it possible to disable phantomId generation or set it in a different field like we can in Schedule's crud manager?
2) If we cannot do anything in (1) or if they're not planned is it ok initialising ids to -1? Will we have any consequences down the road?

Br,
Kaan.

User avatar
pmiklashevich
Core Developer
Core Developer
Posts: 1918
Joined: Fri Apr 01, 2016 11:08 am

Re: phantomIdField for AjaxStore

Post by pmiklashevich » Thu Jul 11, 2019 5:31 pm

Hello Kaan,

Could you please describe the use case you have?

Phantom IDs have to be unique. And while they are new and unsynced to the server, they have some kind of made up id. The response from the server sends back the real id of the new database row, and it gets updated.

Regards,
Pavel
Pavel Miklashevich - Core Developer

User avatar
proteams-kaan
Posts: 12
Joined: Fri Jan 04, 2019 1:22 pm

Re: phantomIdField for AjaxStore

Post by proteams-kaan » Fri Jul 12, 2019 11:37 am

Hi Pavel,

My use case is that in typed languages on the server, it's quite inconvenient to have an id field that is both a string and then an integer (auto incremented id on the db side).

My other points would be that this is readily available in the scheduler component and also the mapping you mention is unstable and I'm guessing it expects the added items to be returned in the same order as there's no other way to detect which phantomId maps to the replaced id since you're loosing information by not having the phantomId in a separate field like we are able to do with Schedule component's crud manager.

Post Reply