Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Tab panel's show called twice

$
0
0
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?

Viewing all articles
Browse latest Browse all 4756

Trending Articles