Results 1 to 6 of 6

Thread: Store / TreeStore get data back

  1. #1
    Sencha Premium Member
    Join Date
    Nov 2012
    Posts
    23
    Answers
    1

    Question Store / TreeStore get data back

    Hi!

    I'm loading data into a Treestore and i would like to get the data back in the same format.

    My problem is that I absolutly don't know how I could do this.
    Currently I use a Ajax Proxy, because this proxy has a getJsonData method, which is call on request send.
    At this point I get some of the data in the way I want, but only on update. When I add a new entry the the create method gets called and I "lose" data.

    If I parse through the entries etc. I get a bunch of data which I dont need and which I also don't want to send back to the Server.

    So someone has some tips for me?

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    I'm sure you've already looked at the tree examples:
    http://examples.sencha.com/extjs/6.2...-treegrid.html
    http://examples.sencha.com/extjs/6.2...-treegrid.html

    Are you able to post a test case showing what you're doing?
    https://fiddle.sencha.com/#view/editor

    If not, can you post your grid config and a sample of your data?

  3. #3
    Sencha Premium Member
    Join Date
    Nov 2012
    Posts
    23
    Answers
    1

    Default

    I tried to rebuild my config in fiddle.

    Now if you click on one of the Buttons and then "Save" the console log will show you the result.
    Further, if I change a child and it's parent I'll get both entries when I call "proxy.lastRequest.getJsonData()" where the child is listed seperatly to its parent and also inside the parent.

    Fiddle

  4. #4
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    I'm not clear on what is being displayed incorrectly. Also, when I select the New Branch button, it successfully adds a leaf to the node I had selected.

  5. #5
    Sencha Premium Member
    Join Date
    Nov 2012
    Posts
    23
    Answers
    1

    Default

    Sorry, I edited the fiddle & my post.
    Everything displays correctly, I just want to get the treedata back as JSON, to save it in another ViewModel.
    The "parentViewModel"-Data will be later send back to the server when everything is configured.

  6. #6
    Sencha Premium Member
    Join Date
    Nov 2012
    Posts
    23
    Answers
    1

    Default

    Maybe I've found a solution that could work.
    When I call the serialize method on the rootnode of the treeStore, I get what I want.
    But.. my rootproperty is not "children" it is 'assistanceitem'.

    So, I tried to override the serialze method, but without success.

    My override looks like this:

    Code:
    Ext.define('Admin.data.NodeInterface', {
        override: 'Ext.data.NodeInterface',
        serialize: function(writerParam) {
            var writer = writerParam || new Ext.data.writer.Json({
                    writeAllFields: true
                }),
                result = writer.getRecordData(this),
                childNodes = this.childNodes,
                len = childNodes.length,
                children, i;
            if (len > 0) {
                result[writer.getRootProperty()?writer.getRootProperty():'children'] = children = [];
                for (i = 0; i < len; i++) {
                    children.push(childNodes[i].serialize(writer));
                }
            }
            return result;
        }
    });

Similar Threads

  1. Replies: 15
    Last Post: 20 Oct 2012, 2:25 PM
  2. Writing TreePanel data back to the store
    By gnube in forum Ext: Q&A
    Replies: 0
    Last Post: 28 Oct 2011, 11:58 PM
  3. Replies: 1
    Last Post: 16 Sep 2011, 7:23 AM
  4. Accessing data in a Treestore of a NestedList after coming back from the server
    By torsten.t in forum Sencha Touch 1.x: Discussion
    Replies: 0
    Last Post: 15 Oct 2010, 8:46 AM
  5. EditorGrid + Store and how to send back modified data
    By alfiewong in forum Ext 2.x: Help & Discussion
    Replies: 11
    Last Post: 20 May 2010, 10:03 AM

Tags for this Thread

Posting Permissions

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