Results 1 to 9 of 9

Thread: problem using the datawriter

  1. #1
    Sencha Premium User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    605

    Default problem using the datawriter

    Solved.
    Last edited by Tim Toady; 3 Mar 2010 at 1:15 PM. Reason: Solved

  2. #2
    Sencha User
    Join Date
    Jan 2010
    Posts
    168

    Default I had the same problem

    Can you post your solution or describe how you fixed?

  3. #3
    Sencha Premium User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    605

    Default

    The problem was that when calling the save function on my store the datawriter wasn't working properly. Remove was not being called and create was being called instead of update. Looking into firebug showed that phantom was not being set properly which was causing the writer to mess up. It all boiled down to the fact that I didn't have a field named 'id'. It would have been nice to have that requirement in the documentation.

  4. #4

    Default

    Here is what happened:

    Every host-side record must have a primary (or at least unique) key, specified in the "idProperty" of the Store. This will correspond to the "id" field.

    For a new record, ExtJS will generate its own temporary, "phantom," record-id. When it submits a create request and receives a list of records in response, it replaces each one of the phantom records (still uniquely identified by its ExtJS-generated ID) with the real ones, which now will carry the host-generated ID.

    This process, like updating, is completely dependent upon ExtJS knowing what a unique identifier of each host-side record is. If you see records "piling up," or not losing their updated status at the right times, yada yada yada, "look at this first."

    ("I've got this scar here, and this bruise over here ..." he said, rolling up his sleeve, "and this bump over on my wrist from slamming it into the keyboard... and ...")

  5. #5
    Sencha User
    Join Date
    Jan 2010
    Posts
    168

    Default I set up an idProperty on my reader/writer

    But am still having that problem. What are you using on the backend to interpret and parse the data.

    maybe I am not including some function properly. I found the writer examples and restful PHP examples fairly convoluted and tried to shortcut by creating a case statement for each xaction. (case create do this, case destroy do this, case....)

    I guess the question is, if you use api in your proxy, do you need to set up the backend php like the examples or is there a different method that can be used? I also have this problem if i use a straight URL and method: "POST"

    Right now, if I create a record, it inserts it into my DB properly, comes back to the row to edit. Any changes I make to that row, send CREATE statements back to the databse and I get multiple inserts.

    On row deleting, I am using a straight AJAX call from the RowEditor. This is working fine except when I delete the last record in the grid, it deletes it from the DB but the store/grid not updating properly and removing that last record from the view.

  6. #6
    Sencha Premium User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    605

    Default

    The backend in that example is complicated. You do not have to do it like that. JS doesn't know anything about the backend. All it knows is what it receives back from it. Having a proxy with only urls in it simply sends the data to different places rather than one.

  7. #7
    Sencha User
    Join Date
    Jan 2010
    Posts
    168

    Default That is the direction I have taken, so I must be doing something else wrong

    What are you sending back after inserting to the url? Another thing I found lacking in documentation. I saw a post that indicated you need to send the complete record back. I am pretty sure I am sending the complete record back, but....still stabbing. So close but so far....

  8. #8
    Sencha Premium User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    605

    Default

    I haven't written the insert yet. I know for the removal I had to echo '{"success":true}'; for the datawriter to not add it back to the store. My other create/update functions are empty functions at the moment. Just look at the examples response in firebug.

  9. #9
    Sencha User
    Join Date
    Jan 2010
    Posts
    168

    Default Gotcha

    I was only echoing "success:true" early on and having the problem, so when you get to the insert we may be conversing again....thanks. I will load the example and check it out.

Posting Permissions

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