Results 1 to 4 of 4

Thread: [SOLVED] ComboBox with Template in EditorGridPanel

  1. #1
    Sencha User
    Join Date
    Jun 2009
    Location
    Colorado
    Posts
    51

    Default [SOLVED] ComboBox with Template in EditorGridPanel

    I am attempting to use a template with a combobox inside an editorGridPanel, and having issues getting the template to recompile based on the currently selected row. The template is as follows:

    Code:
    var usageTpl = new Ext.XTemplate(
        '<tpl for="."><div class="search-item">',
            '<tpl if="this.isDefault(attribute_id)">',
                '<b>',
            '</tpl>',
            '<p>Usage: {name}</p>',
            '<tpl if="this.isDefault(attribute_id)">',
                '</b>',
            '</tpl>',
        '</div></tpl>',
        {
            isDefault: function(attribute_id)
            {
                return productsGrid.getSelectionModel().getSelected().data.product_usages.indexOf(attribute_id) >= 0;
            }
        }
    );
    The point of the template is to make some of the items in the list bold based on the data in the currently selected record. The template functions as planned the first time, but doesn't seem to recompile when the combobox is expanded in a different row. Is there a best practice or example of this? Thanks.

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256

    Default

    The combo uses a DataView to show the list and it's only ever created once. You'd be best off creating a combo subclass that re-creates the list where appropriate.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

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

    Default

    Don't reference the grid from the template.

    Instead, change the template from the beforeedit event of the grid.

    ps. After changing the template you either need to reload the store or refresh the inner dataview list.

  4. #4
    Sencha User
    Join Date
    Jun 2009
    Location
    Colorado
    Posts
    51

    Default

    Hey, thanks a lot. The trick was combo.view.refresh() from the beforeedit event of the grid. Don't know why that was so difficult for me to find.

    By the way, is it just me or does the "update" function listed in the docs for the combobox not actually exist?

    Also -

    Quote Originally Posted by Condor
    Don't reference the grid from the template.
    I am still doing this.. should I be concerned? It seems a combination of forcing view to refresh, which makes the template re-render, and building the template based on the currently selected row gets me where I need to be - but maybe I am missing something again?

    Thanks again.

Similar Threads

  1. Replies: 1
    Last Post: 17 Jun 2010, 4:34 PM
  2. ComboBox Template
    By ajmPal in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 15 Apr 2010, 8:21 AM
  3. ComboBox Template
    By ajmPal in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 12 Apr 2010, 3:48 AM
  4. combobox template
    By Radziu in forum Ext 2.x: Help & Discussion
    Replies: 14
    Last Post: 3 Aug 2008, 11:29 PM

Tags for this Thread

Posting Permissions

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