Page 4 of 4 FirstFirst ... 234
Results 31 to 38 of 38

Thread: ExtDirect4DotNet started

  1. #31
    Sencha User
    Join Date
    Apr 2010
    Posts
    4

    Default

    Hey guys,

    Thanks a lot for your answers!

    But by replacing ext calls to cachefly, which worked just fine, I realized that my problem indeed had something to do with my localhost (well, not quite! ;-)). After that, by diggin' a bit through the web, I was able to fix the problem. I quote from the web site I attach below:

    "It turns out that the slowness is caused by an IPv6 issue with DNS and can easily be resolved by turning IPv6 support off in Firefox while doing localhost testing. To make the change, type about:config in the address bar, locate the network.dns.disableIPv6 setting and double-click on it to set it to true. This does the trick for the Firefox localhost issue on Vista and everything is running fast again."

    Now, I use Windows7, but nonetheless, I Changed this setting and things are smooth as they are supposed to!

    here's the URL: http://weblogs.asp.net/dwahlin/archi...-on-vista.aspx

    Thanks again and best regards!

  2. #32

    Default Support for Ext JS 4.x

    Hi,

    Are there any plans to update ExtDirect4DotNet to support Ext JS / Direct 4.x?

  3. #33
    Ext JS Premium Member sreeser's Avatar
    Join Date
    Jan 2011
    Posts
    3

    Question Problem using direct proxy on model

    I'm using ExtJS 4 with the MVC model for an app and am running into a javascript error when I try to create a new record. My app is very similar to the MVC example from the docs.

    I'm creating a new record (instance of the model) and after setting its values I call the save method on it.I get an error at line 26607 of ext-all-debug.js which is the callback for the save function. It is looking for the record attached to the response and it sees that 'resultSet' is defined and looks for the first element in it. but 'resultSet' is an empty array. The data from the request is stored in the 'records' property

    Here is my model code with the proxy defined:
    Code:
    Ext.define('AM.model.User', {
        extend: 'Ext.data.Model',
        requires: ['Ext.direct'],
        fields: [{name:'id',type:'int'},'name', 'email'],
        proxy: {
            type: 'direct',
            api: {
                create: AccountManagerExchange.Create,
                read: AccountManagerExchange.Read,
                update: AccountManagerExchange.Update,
                destroy: AccountManagerExchange.Delete
            },
            reader: {
                root: 'data'
            }
        }
    });
    Here is my store:
    Code:
    Ext.define('AM.store.Users', {
        extend: 'Ext.data.Store',
        model: 'AM.model.User',
        autoLoad: true
    });
    Here are the functions that create the record and attempt to save it after the user fills a form:
    Code:
    // Updates account when user presses save in editor
    updateAccount: function(button) {
        var win    = button.up('window'), // Get the editor window
            form   = win.down('form'), // Get the editor form
            record = form.getRecord(), // Get the record that was loaded into the form
            values = form.getValues(); // Get the values from the form
        // Set the record's values to the updated 
        record.set(values);
        // Save the record to the server
        record.save();
        // Get rid of the dirty markers on fields after saving
        record.commit();
        win.close();
    },
    // Creates a new account and opens editor when user presses Create from the grid
    createAccount: function(button) {
        // Create the new user record
        var newUser = Ext.create('AM.model.User');
        // Open a new edit window for the new user
        var view = Ext.widget('useredit', {isNewAccount: true});
        // Find the form and load the new user record
        view.down('form').loadRecord(newUser);
    }
    Up to this point everything works fine, the model sends the correct action to the server which adds the user just fine. The request and response looks like this:
    Code:
    Request:
    {
        "action":"AccountManagerExchange",
        "method":"Create",
        "data":[{
            "id":0,
            "name":"testUser",
            "email":"[email protected]"
        }],
        "type":"rpc",
        "tid":2
    }
    
    Response:
    [{
        "type": "rpc",
        "name": null,
        "tid": 2,
        "action": "AccountManagerExchange",
        "method": "Create",
        "result": {
            "id": 3,
            "name": "testUser",
            "email": "[email protected]"
        },
        "message": null,
        "where": null,
        "errorcode": 0
    }]
    As you can see the result has had the id updated. When the callback for the save action is executed the Ext.data.Operation has a resultSet property (an Ext.data.ResultSet) which has no records in it. The operation's response property has a result defined as the object that was expected. It is not wrapped in an array.

    I tried to include all helpful information, if there is any information that would be useful please let me know. Thank you for your response,
    Sean

    Edit: I solved my problem, I just had to wrap the return value in an array.
    Last edited by sreeser; 13 Oct 2011 at 9:39 AM. Reason: Solved

  4. #34
    Sencha User
    Join Date
    Dec 2008
    Location
    Mainz
    Posts
    241

    Thumbs up

    Was just about to dive into your problem good to know you solved it by yourself!

  5. #35
    Ext JS Premium Member
    Join Date
    Jan 2012
    Posts
    20

    Default

    How would I need to set up my direct method to

    ResourcePresenter.SaveResources(resourceArray, callback);


    Right now I have it like this and it works when store.sync magically does everything for me. I want to start calling these things myself.
    Code:
    [DirectMethod]
            public ResourceDto[] SaveResources(Dictionary<string, object> callParams)
            {
                var resourceClient = new ResourceClient();
    
    
                List<ResourceDto> list = new List<ResourceDto>();
    
    
                foreach (var kvp in callParams)
                {
                    if (kvp.Value is JObject)
                        list.Add(JsonConvert.DeserializeObject<ResourceDto>(kvp.Value.ToString()));
                    else if (kvp.Value is JArray)
                        foreach (var obj in kvp.Value as JArray)
                            list.Add(JsonConvert.DeserializeObject<ResourceDto>(obj.ToString()));
                }
    
    
                ResourceDto[] resourceDtos = list.ToArray();
                return resourceClient.SaveResources(resourceDtos);
            }

  6. #36
    Sencha User
    Join Date
    Dec 2008
    Location
    Mainz
    Posts
    241

    Default

    I am not sure if I got the point here...

    what about
    Code:
    ResourcePresenter.SaveResources({ rows : [ { name : 'test' } // in this case the structure of your ResourceDto ] }, function() { console.log(arguments); // or your logic after comit on the server }, this /* the scope the function should get called with */);
    But usually you shouldn't need to call this method by hand because your store should take care of the communication with the server....

    regards Martin

  7. #37
    Ext JS Premium Member
    Join Date
    Jan 2012
    Posts
    20

    Default

    Thanks, this ended up working. Do you happen to know how to get ahold of the request tid so I can link it up to the response tid?

    Code:
    handleSaveResources: function (button) {
          var store = Ext.data.StoreManager.lookup('Resources');
          var updatedRecords = store.getUpdatedRecords();
          var updatedRecordsData = new Array();
    
    
          for (var i = 0; i < updatedRecords.length; i++) {
             updatedRecordsData[i] = updatedRecords[i].data;
          }
          
          ResourcePresenter.SaveResources({
             records: updatedRecordsData 
    
    
          }, function (data, metaData) {
                     console.log(arguments); 
          }, this /* the scope the function should get called with */);
       }

  8. #38
    Sencha User
    Join Date
    Dec 2008
    Location
    Mainz
    Posts
    241

    Default

    I don't get it.
    If you bypass the Store that way you end up with only one Transaction. The one used to call the Direct Function.

    What do you actually want to do here? And what ended up working?

    regards Martin

Page 4 of 4 FirstFirst ... 234

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •