Results 1 to 2 of 2

Thread: Generic model posting params instead of id

  1. #1
    Ext JS Premium Member Asken's Avatar
    Join Date
    Feb 2010
    Location
    sweden
    Posts
    122

    Default Generic model posting params instead of id

    Hi guys,

    I've been looking around at the forum and can't find a solution for using a model. We're using composite keys and are partitioning our data based on these keys so we can not use Id.

    I want my server to provide the model as it's all known there. I get fields, validations and other stuff like proxy and set it to the model. So far so good.
    Code:
    Ext.define(modelName, {
        extend: 'Ext.data.Model',
        fields: obj.data.fields,
        validations: obj.data.validations,
        proxy: {
          type: 'ajax',
          url: appPath + '/data/Profile/',
          /*actionMethods: {
            read: 'POST'
          },*/
          api: {
            read: appPath + '/data/Profile/Get'
          },
          reader:   {
            type: 'json'
          }
        }
      });
    Then all I want to do is this:
    Code:
    Profile.load({
      params: { userName: 'Kristian', variable2: value2, ... }
    })
    What it does it it sends
    HTML Code:
    .../profile?id=Object object
    Where Object object is the "params.toString()". I've tested using POST in the proxy but I get "Object object" for the id parameter.

    What I want to do is to not send the id parameter but my own params. Anyone knows how to do this the proper way? Only solution I've come up with is to post the decoded json as the id parameter and encode it server-side again but that doesn't feel right

    /K
    Last edited by Asken; 29 Jun 2011 at 6:15 AM. Reason: RESOLVED

  2. #2
    Ext JS Premium Member Asken's Avatar
    Join Date
    Feb 2010
    Location
    sweden
    Posts
    122

    Default

    Found it out... first parameter is id, next is config:
    Code:
    load: function(id, config) {
      config = Ext.apply({}, config);
      config = Ext.applyIf(config, {
        action: 'read',
        id    : id
      });
    ...
    Why isn't it not just config sent in checking if it's an object containing id, if not just assume that it's the id being passed in?

    Code:
    Profile.load(null, {
      params: { userName: 'Kristian', variable2: value2, ... }
    })

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
  •