PDA

View Full Version : [CLOSED] REST store sync callback



thesvr
Nov 06, 2012, 8:01 AM

Daniil
Nov 06, 2012, 12:20 PM
Hi @thesvr,

Welcome to the Ext.NET forums!

Currently, a sync method returns undefined. "!undefined" gets true in JavaScript. Therefore you see "test2" every time.

I tested a callback. It works well for me. Please clarify can't you see a "test1" message at all?



The REST proxy response is:

{
"valid": true,
"message": "Saved"
}


Now in Ext.NET 2 and ExtJS 4, a response must contain saved records. Please look at this example.
http://examples2.ext.net/#/GridPanel/Update/AutoSave/

thesvr
Nov 06, 2012, 8:39 PM
Indeed I don't get a "test 1" alert.

I looked at the example, to me it looks like it just handles exeptions and no success.

I also implemented the callback in the example using:


<Click Handler="#{Store1}.sync({
callback: function(records, operation, success) {
alert('test');
}
}
);" />

In modified the example I also don't get an alert.

Vladimir
Nov 06, 2012, 10:09 PM
The issue with callback was fixed in 2.1 version
I suggest to update from 2.1 branch and retest

thesvr
Nov 07, 2012, 8:01 AM
The issue with callback was fixed in 2.1 version
I suggest to update from 2.1 branch and retest

Hi it works for me using 2.1 branch and the function bellow. However I run into some other issues using the 2.1 branch. That makes me wonder if the 2.1 branch is suitable for a production environment?


var savestore = function (store) {

var g = store.getNewRecords(), d = store.getUpdatedRecords(), a = store.getRemovedRecords();
if (g.length > 0 || d.length > 0 || a.length > 0) {
store.sync({
callback: function (records, operation) {
alert('synced');
}
});
}
else {
alert('nothing to sync');
}
}

Vladimir
Nov 07, 2012, 10:48 AM
Yes, branch 2.1 is quite stable and will be released soon
Can you describe the issues? We will be glad to fix it asap

thesvr
Nov 07, 2012, 2:48 PM
Yes, branch 2.1 is quite stable and will be released soon
Can you describe the issues? We will be glad to fix it asap

Okay I expected this answer so I am working on the migration to 2.1. Here are the issues I am currently working on:

1. Model datetime format
Using Ext.net 2.0 i used M$ as dateformat in my model for date field. In 2.1 are these send back as "\date\" format. This resulted in difficulties to process at the webservice.
Using
yyyy-MM-dd\\THH:mm:ss as dateformat solved the issue. Looks like: http://forums.ext.net/showthread.php?21221-CLOSED-Store-Sync-Date-Problem

During the debugging I saw the advantages of ISO 8601. It offers an ability to eliminate timezone issues by using an UTC time in the format 2011-01-01T00:00:00.0000000Z (
.ToString("O") ). For now I could not find an easy way to configure the model to use this format (especially the conversion to UTC).

2. Partial view is not completely destroyed
I have got a partial view in a tabpanel. When closing the tab the content is not destroyed when using
Ext.Net.RenderMode.RenderTo during it's creation. However when using
Ext.Net.RenderMode.Auto it works.

3. RESTProxy, JSONreader /writer and root setting
I have trouble reading and writing JSON when setting Root property in a REST proxy. When I removed the data level in store and JSON it works. When removing the data layer in JSON it looks as-well. So it looks like if the Root setting is ignored.

My store simplified:

.Store(store => store.Add(Html.X().Store()
.PageSize(100)
.ID("testStore")
.Proxy(proxy => proxy.Add(
Html.X().RestProxy()
.Url(Url.Action("API", "api"))

))
.Reader(reader =>
Html.X().JsonReader()
.IDProperty("row_id")
.Root("data")
.SuccessProperty("success")
.MessageProperty("message")
)
.Model(model => model.Add(Html.X().Model()
.Fields(fields =>
{

fields.Add(Html.X().ModelField().Name("test"));


})
))
))

Daniil
Nov 08, 2012, 12:57 PM
Okay I expected this answer so I am working on the migration to 2.1. Here are the issues I am currently working on:

1. Model datetime format
Using Ext.net 2.0 i used M$ as dateformat in my model for date field. In 2.1 are these send back as "\date\" format. This resulted in difficulties to process at the webservice.
Using
yyyy-MM-dd\\THH:mm:ss as dateformat solved the issue. Looks like: http://forums.ext.net/showthread.php?21221-CLOSED-Store-Sync-Date-Problem

During the debugging I saw the advantages of ISO 8601. It offers an ability to eliminate timezone issues by using an UTC time in the format 2011-01-01T00:00:00.0000000Z (
.ToString("O") ). For now I could not find an easy way to configure the model to use this format (especially the conversion to UTC).

There are a ModelField's DateWriteFormat and a Write's DateFormat options.
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Field-cfg-dateWriteFormat
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.writer.Writer-cfg-dateFormat

We think they could help.



2. Partial view is not completely destroyed
I have got a partial view in a tabpanel. When closing the tab the content is not destroyed when using
Ext.Net.RenderMode.RenderTo during it's creation. However when using
Ext.Net.RenderMode.Auto it works.

3. RESTProxy, JSONreader /writer and root setting
I have trouble reading and writing JSON when setting Root property in a REST proxy. When I removed the data level in store and JSON it works. When removing the data layer in JSON it looks as-well. So it looks like if the Root setting is ignored.

My store simplified:

.Store(store => store.Add(Html.X().Store()
.PageSize(100)
.ID("testStore")
.Proxy(proxy => proxy.Add(
Html.X().RestProxy()
.Url(Url.Action("API", "api"))

))
.Reader(reader =>
Html.X().JsonReader()
.IDProperty("row_id")
.Root("data")
.SuccessProperty("success")
.MessageProperty("message")
)
.Model(model => model.Add(Html.X().Model()
.Fields(fields =>
{

fields.Add(Html.X().ModelField().Name("test"));


})
))
))

Could you, please, start new forums threads with samples to reproduce? We will appreciate.