Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Store - Supress Specific Actions

  1. #1
    Sencha User
    Join Date
    Jun 2009
    Location
    Burlington, Ontario
    Posts
    175

    Default Store - Supress Specific Actions

    I have a store associated to a gridpanel, and I want to be able to suppress calls to the create action based on my own criteria, but if there are other actions such as update/destroy, etc I would like them to continue.

    So, in short, is it possible to tell a store to save but exclude any create calls?

  2. #2
    Ext User
    Join Date
    Sep 2010
    Location
    Baltimore, MD
    Posts
    66

    Default Try Proxy

    In your store instead of just setting the URL, use the Proxy with something like
    ProxyConfig = {
    api : { read : {url: yourURL, method: 'GET' } }
    }
    etc
    Under the api you can explicitly set the different operations, so you could null out the create and delete

    Quote Originally Posted by Bleak View Post
    I have a store associated to a gridpanel, and I want to be able to suppress calls to the create action based on my own criteria, but if there are other actions such as update/destroy, etc I would like them to continue.

    So, in short, is it possible to tell a store to save but exclude any create calls?

  3. #3
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    You could create your Record class with an isValid method that returns false for phantom records (invalid fields are never saved).

  4. #4
    Sencha User
    Join Date
    Jun 2009
    Location
    Burlington, Ontario
    Posts
    175

    Default

    Hey Foster,

    I do use a proxy, however, I want to be able to turn the create proxy on/off as necessary. I've tried;

    PHP Code:
     this.dao.getProxy().setApi(Ext.data.Api.actions.createnull); 
    The dao class has the following method
    PHP Code:
      //The dao getProxy() Method is defined as;
       
    getProxy: function() {

            if (! 
    this.proxy) {
                
    this.proxy = new Ext.data.HttpProxy({
                    
    api: {
                        
    read :'pp.do?xaction=read',
                        
    create'pp.do?xaction=create',
                        
    update'pp.do?xaction=update',
                        
    destroy'pp.do?xaction=destroy'
                    
    }
                });
            }

            return 
    this.proxy;

    But if I attempt to set the create call to null, it just throughs an error. The idea is to be able to turn the create call on/off as necessary based on criteria.

    Is there a correct way to change the proxy settings dynamically?

  5. #5
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    Any specific reason you want to disable 'create' requests?

    Couldn't you modify the GUI so the user isn't able to insert records when no allowed?

  6. #6
    Sencha User
    Join Date
    Jun 2009
    Location
    Burlington, Ontario
    Posts
    175

    Default

    This is stemming from always having an extra record in the grid for the purpose of the user being able to enter a new record right from the editor grid. There are a couple of columns that are required by the backend to allow the record to be created and these require user input. Right now, the create method is called with no data, which the back end handles appropriately but it just seems like a wasted call entirely since the record is blank.

    What I've done, is added an event that is triggered before the store calls save and it checks to see if there are any records pending for create, and if the required fields are not populated, I want the create call to be skipped, but any outstanding update/destroy requests to continue through.

  7. #7
    Ext User
    Join Date
    Sep 2010
    Location
    Baltimore, MD
    Posts
    66

    Default

    Hey Dean,

    I tried to find an example in my app where I did something similar but couldnt find one. I know I never explicitly set any part of the api config to null after instantiation, I just left off the declarations in my initial definition, and it ends up set to undefined.

    This might not be the most elegant fix, but can you try:

    Add a beforeWrite listener to the store itself, which should get passed the proxy and the action, and if you return false there it should abort the create. You could potentially use logic there, or check if the api.create is null and abort, otherwise perform the create.

    -Foster

  8. #8
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    As I said, handle this by making the record with emtpy data invalid.

    Marking one or multiple fields with allowBlank:false will take care of that.

  9. #9
    Sencha User
    Join Date
    Jun 2009
    Location
    Burlington, Ontario
    Posts
    175

    Default

    Condor, thanks! I can't believe I didn't think to look at the record definition to specify required fields. This worked, perfectly.

    Foster, the beforeWrite listener also worked, thanks for the approach.

  10. #10
    Sencha User
    Join Date
    Jun 2009
    Location
    Burlington, Ontario
    Posts
    175

    Default

    Hey Condor,

    Bit off topic, but whats the best method for determining if a phantom record exists in a store? I iterate over the records right now checking each records phantom attribute, but thinking there must be a proper way?

Page 1 of 2 12 LastLast

Similar Threads

  1. How to determine whether a specific record exist in the Store?
    By aladdinwang in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 23 May 2010, 4:33 AM
  2. How to supress an event in Ext
    By sam_ware in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 6 May 2010, 10:04 PM
  3. Supress contextmenu event on row in GridPanel?
    By dbassett74 in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 30 Jul 2009, 2:02 PM
  4. Reload Data Store but update only specific row in grid...
    By wurstkuchen in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 21 Apr 2009, 5:05 AM

Posting Permissions

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