Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Tab panel's show called twice

    I am using SmartClient 10 evaluation version of October 13th, 2014 on the latest Chrome on MacOS 10.9.5.

    I have a SectionStack that I add as the first tab in the initWidget method of a class inheriting from TabSet. The section stack has a ListGrid in it and when the TabSet is created, I want it to fetch the data of the grid. Because I have a search form, I don't want to use autoFetch on the List, so I manually call it.

    I now use the show() method of SectionStack and I notice the data is fetched twice. I tricked the show method in delete itself after executing, but that doesn't seem right.

    Should I use another point to fetch the data?

    The code is more or less like this (any advice if this is bad practice in some way is of course welcome)

    Code:
    (function (isc) {
      'use strict';
    
      isc.defineClass('MyTabSet', isc.TabSet).addProperties({
        initWidget: function () {
          this.Super('initWidget', arguments);
          this.addTab({
            pane: sectionStack(),
            title: 'Records'
          }];
        }
      });
    
      sectionStack = function () {
        var grid, searchForm, stack;
    
        function loadData() {
          grid.fetchData(searchForm.getValues());
        }
    
        searchForm = isc.DynamicForm.create({
          ...
        });
    
        grid = isc.ListGrid.create({
          dataSource: isc.RestDataSource.create({
            ...
          })
        });
    
        stack = isc.SectionStack.create({
          sections: [{
            canCollapse: false,
            expanded: true,
            controls: [searchForm],
            items: grid
          }],
          show: function () {
            this.Super('show', arguments);
            // when the section stack is first shown, fetch the grid's data
            loadData();
            // the show method on this prototype will be removed
            // delete this.show;
          }
        });
    
        stack.observe(searchForm, 'submit', loadData);
    
        return stack;
      };
    }(this.isc));
    I use the section stack to have a search form in its header. In my real application I also add buttons for creating, editing and deleting records. Is this a good approach or can I prevent the usage of the section stack at all and add a header to the grid directly or something?

    #2
    It looks like you are probably drawing twice causing show to be (correctly) called twice. See canvas.autoDraw.

    Comment


      #3
      I've turned autoDraw off globally and did check by explicitly switching it off. Without success. I will prepare a working example soon.

      Comment


        #4
        I will not give the promised example, because I discovered that I can add a toolstrip to a grid (via the gridComponents property), so I've changed the whole approach and the original problem is no longer there.

        Comment

        Working...
        X