We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14951
    • 151 Posts
    I'm not sure if the title is appropriately stating what I'm trying to do, but in layman's terms...

    I have a grid with records. When I update a record, I have a window to edit the fields. Within the window, I have an additional grid.

    I need to push the ID of the record I'm editing to the grid that lies within the update window.

    In my updateItem function I have:
    var pid = this.menu.record.id;
    this.updateItemWindow.relation = pid;
    


    In my updateItemWindow I have:
    console.log(this);


    This correctly shows "relation: 2" (Or whatever id I update)

    If I switch it to:
    console.log(this.relation);

    It shows "undefined".

    This doesn't make sense because it clearly shows that "relation" is correctly populated with the ID with the console.log(this) command.

    So I'm wondering if "this.relation" is not the proper way to access the property?

    If it would help to see my code, it is posted here: https://gist.github.com/3174633

    Thank you so much in advance for any insight in regards to this... Getting pretty desperate to figure out this silly item..

    -Jared
      • 4172
      • 5,888 Posts
      this is more a extjs-question than a modx-question.
      What I can say, without looking to deep into your code: I'm sure, MIGXdb could do this, what you are trying.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 14951
        • 151 Posts
        Thanks Bruno,

        I didn't know that MIGXdb was capable of handling multiple windows and grids etc.. I actually tried to start with MIGXdb, but ended up thinking that it wasn't able to handle my needs.

        Do you think that my Extjs question is too much for these forums? If so do you have any good recommendations for a good Ext forum?

        Thanks!
        -Jared
          • 33968
          • 863 Posts
          Hi Jared

          You can always try the Sencha forums for ExtJS assistance but I've found you don't get much of a response and the participants are often quite arrogant (especially the core team).

          I'd love to have more discussion about MODExt/ExtJS in these forums as it's very relevant to Revo development smiley


          I think your problem is you are calling console.log(this) immediately when the Window is initialised - you are setting this.relation after it is initially loaded so that's why it's undefined. I wouldn't call myself an ExtJS expert but I've certainly come across this issue before.

          If you add your console.log on line 132 the relation value should show up:
          this.updateItemWindow.show(e.target);
          console.log(this.updateItemWindow);
          


          The thing is, because you are showing and hiding your window the grid contained in it is only going to be rendered once and the store only loaded on the first time. Changing the Window config is not going to have any effect as it's only used for the initial setup.

          I would probably restructure your updateItem code like this, giving your item grid an id (,id: 'id-of-item-grid') and reload it with the new 'pid' value before re-showing the window.:
          updateItem: function(btn,e) {
              var pid = this.menu.record.id;
              if (!this.updateItemWindow) {
                  this.updateItemWindow = MODx.load({
                      xtype: 'easyinventory-window-item-update'
              	    ,params: {
              	        pdid: this.menu.record.id  // not really sure what this does?!
              	        ,relation = pid  // isn't this the same value as pdid?
              	    }
              	    ,listeners: {
              	        'success': {fn:this.refresh,scope:this}
              	    }
                  });
              } else {
                  // reload your item grid with new pid
                  var itemGrid = Ext.getCmp('id-of-item-grid'),
                      itemGridStore = itemGrid.getStore();
                  itemGridStore.baseParams.pid = pid;
                  itemGrid.getBottomToolbar().changePage(1);
                  itemGrid.refresh();
              }
              this.updateItemWindow.setValues(this.menu.record);
              this.updateItemWindow.show(e.target);
          }
          

          Note I didn't really understand exactly what 'pid' and 'pdid' are doing but I hope that helps a little. Not tested!

          Luke [ed. note: okyanet last edited this post 14 years, 2 months ago.]
            • 14951
            • 151 Posts
            Hey Luke!

            Thank you very much for the tips! I too really wish there was more discussion on ExtJS here specifically MODExt. I've really struggled with figuring out how and more importantly "when" things are instantiated but your tip gave me the idea to start moving "console.log(this)" to different places to see what's happening.

            In regards to the couple of questions you had...my pdid and pid were in-fact the same thing...I just left a couple of my "failed" attempts at figuring this issue out =)

            pid or paid is the id of the product I select to update from the grid. There are two addition grids (as well as associated tables in the db) which contain product options and product images. There relation is based on the id of the product so that is why I'm trying to get that information to the grid.

            I still haven't quite figured out how to get that value into my secondary grid but I think I'm a big step forward because of your help!

            Thank you very much for the direction and of course I very much welcome any further advice or tips you may have as this is very much foreign territory to me.

            Thank you kindly!
            -Jared