Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 15 total
Thread use local storage temporary
Mon, Jan 13 2014 10:25 AMPermanent Link

Mike

Hi,

How can values which are filled out in editable fields be stored (save) in local storage (without using a database) and the values loaded in fields of another screen?

Is this possible? I checked the datasetclient example but can’t figure it out.

The dataset is already created and columns are defined.




Mon, Jan 13 2014 12:15 PMPermanent Link

Matthew Jones

You can use browser storage for some things:

  szLocalGUID := Window.LocalStorage.GetItem('my_guid');

The data can be quite large, but is uninitialised so you have to watch for that
too.

If you are just storing data for a "global" variable to use in another form of the
same application then you can just use a normal pascal global variable.

/Matthew Jones/
Mon, Jan 13 2014 1:16 PMPermanent Link

Mike

Thank you for the response.

Is it not possible to save the fields to a dataset (defined at design time) via

LocalStorage.Set(dsDocuments.DataSetName, dsDocuments.GetRows);

and load them via

dsDocuments.LoadRows(LocalStorage.Items[dsDocuments.DataSetName]);
?

I would like to use to add these values to a grid on another form.
Mon, Jan 13 2014 3:27 PMPermanent Link

Matthew Jones

<Mike> wrote:
> Thank you for the response.
>
> Is it not possible to save the fields to a dataset (defined at design time) via
>
> LocalStorage.Set(dsDocuments.DataSetName, dsDocuments.GetRows);
>
> and load them via
>
> dsDocuments.LoadRows(LocalStorage.Items[dsDocuments.DataSetName]);
> ?
>
> I would like to use to add these values to a grid on another form.

First, you can probably get the JSON for the database that the grid has
behind it. Second, if it is another form, then you can just pass it in a
variable to a property getter/setter of the form. The localstorage is only
for when you want the data to still be there next week when they load your
application.

--
Matthew Jones
Mon, Jan 13 2014 3:49 PMPermanent Link

Mike

The grid on the other form is using the dataset. The dataset is never connected to a database.

Is it always necessary to connect to a database when using a dataset?

When I use the following code:

szLocalGUID := Window.LocalStorage.GetItem('my_guid');

the message "[Error] Unit1.wbs (29,3): The referenced variable, parameter, or function Window does not exist" appears.
Mon, Jan 13 2014 5:30 PMPermanent Link

Walter Matte

Tactical Business Corporation


Do you have the HTML 5 flag turned on?

Just a guess...

Walter
Mon, Jan 13 2014 5:40 PMPermanent Link

Mike

Yes the HTML 5 flag is turned on.
Mon, Jan 13 2014 8:17 PMPermanent Link

Raul

Team Elevate Team Elevate

On 1/13/2014 3:49 PM, Mike wrote:
> Is it always necessary to connect to a database when using a dataset?
No - you can load it from JSON direct. You still need to generate the
initial json string though representing initial data.

See here for JSON specs and some samples :
http://www.elevatesoft.com/manual?action=viewtopic&id=ewb1&topic=JSON_Reference



> When I use the following code:
> szLocalGUID := Window.LocalStorage.GetItem('my_guid');
> the message "[Error] Unit1.wbs (29,3): The referenced variable, parameter, or function Window does not exist" appears.

You need to add WebDom to the uses clause.

Raul


Tue, Jan 14 2014 5:30 AMPermanent Link

Chris Holland

SEC Solutions Ltd.

Avatar

Team Elevate Team Elevate

try including the WebDom unit in the uses clauses.

Chris Holland
[Team Elevate]

On 13/01/2014 20:49, Mike wrote:
> The grid on the other form is using the dataset. The dataset is never connected to a database.
>
> Is it always necessary to connect to a database when using a dataset?
>
> When I use the following code:
>
> szLocalGUID := Window.LocalStorage.GetItem('my_guid');
>
> the message "[Error] Unit1.wbs (29,3): The referenced variable, parameter, or function Window does not exist" appears.
>
Tue, Jan 14 2014 5:45 AMPermanent Link

Matthew Jones

> No - you can load it from JSON direct. You still need to generate
> the initial json string though representing initial data.

To be clear, you can start with very little JSON to start with nothing.

Tim gave this example:

MyDataSet.LoadRows('{ rows: [] }');

With that done, you can then manually (in code) add data to the dataset, and it
will appear appropriately on the grid display.

/Matthew Jones/
Page 1 of 2Next Page »
Jump to Page:  1 2
Image