1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    15
    Vote Rating
    0
    AesonErryl is on a distinguished road

      0  

    Default Unanswered: How to pass a parameter from model to a web service?

    Unanswered: How to pass a parameter from model to a web service?


    I am working on this.

    In my CONTROLLER JS:
    Code:
    //more codes above
        var isPublic = myAddNewTaskProject.down('[name=chbIsPublic]').getRawValue();
    
    
        var record = new App.model.Project.prototype.newRecord(isPublic); //I want to pass the IsPublic value
        record.data.title = projName;
        record.data.description = descrip;
    
    
        record.save();
    //more codes below
    In my Model JS:
    Code:
    Ext.define('App.model.Project', {
      extend: 'Ext.data.Model',
      fields: [
            { name: 'projectid', type: 'string' },
            { name: 'title', type: 'string' },
            { name: 'description', type: 'string' },
            { name: 'ownerPersonid', type: 'string' }
        ],
      proxy: {
        type: 'rest',
        url: 'services/project/'
      },
      newRecord: function (isPublic) { //I don't know what's next.
        var record = App.model.Project.create();
        return record;
      }
    });

    In my WebService.cs File:
    Code:
    [Post(UriTemplate = "/project/")]
        public SingleResult<Project> SaveProject(Project project, bool isPublic) { //this is where I'll use my isPublic value
    
    
          if(isPublic) {
            project.OwnerPersonID = null; //do not assign owner
          } else {
            project.OwnerPersonID = ContextPersonID; //assign an owner of the project
          }
    
    
          TimeTrackerController.Save(project);
          return new SingleResult<Project>(project);
        }
    I want to pass the value of the 'IsPublic'. But how can I do that inside my Model?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,327
    Answers
    3540
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Set it as a parameter
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1