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

Thread: Grouped grid won't show data name in group header

  1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    10

    Default Grouped grid won't show data name in group header

    Hi there,

    I'm trying to create a grouped grid, like in this Sencha example.

    But I can't manage to have the 'name' field displayed on the group header (American, Asian,... in the example). It just displays 'Cuisine :'

    Is there something I should know about this part of code ? :
    Code:
    var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{         
    groupHeaderTpl: 'Cuisine: {name} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})'     
    });
    Putting the field name between braces isn't enough ?

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,409
    Answers
    716

    Default

    You would also need to update the getGroupString:

    Code:
    getGroupString: function(instance) {
        return instance.get('cuisine') + '/' + instance.get('pricing') + '/' + instance.get('name')
    },
    Regards,
    Scott.

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    10

    Default

    I don't see this function in the groupgrid.js file. Should I add it ? Where ?

    I'm sorry if this is obvious but I'm really new to ExtJS.
    Thanks for your answer

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,409
    Answers
    716

    Default

    Add this to your store:

    Code:
    var Restaurants = Ext.create('Ext.data.Store', {
        storeId: 'restaraunts',
        model: 'Restaurant',
        sorters: ['category'],
        groupField: 'category',
    	getGroupString: function(instance) {
    	    return instance.get('cuisine') + '/' + instance.get('pricing')
    	},
    ..
    Scott.

  5. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    10

    Default

    Still doesn't work, I don't know what I'm doing wrong but obviously there is something...

  6. #6
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,409
    Answers
    716

    Default

    Can you post your code so we can have a look?

    Regards,
    Scott.

  7. #7
    chramer's Avatar
    Join Date
    Feb 2011
    Location
    Chisinau, Moldova
    Posts
    316
    Answers
    64

    Default

    Show us your store declaration!

  8. #8
    Sencha User
    Join Date
    Apr 2012
    Posts
    10

    Default

    My mistake, I found the problem, I forgot to delete a line which was trying to define something else for the header.

    But I still have a question. Now my header is "Group: 'the group title' ".
    Is there a way to just have 'the group title' or to change the word Group for another one ?

  9. #9
    chramer's Avatar
    Join Date
    Feb 2011
    Location
    Chisinau, Moldova
    Posts
    316
    Answers
    64

    Default

    Code:
    groupHeaderTpl: '{name}' //only the <group_title>
    ..
    groupHeaderTpl: 'SOMETHINGELSE : {name}' //SOMETHINGELSE : <group_title >

  10. #10
    Sencha User
    Join Date
    Apr 2012
    Posts
    10

    Default

    OOOOH I just understood something !
    When you write {name} it's not because your grouping field is called 'name'. In the Sencha example there are two fields: name and cuisine so I thought that if my field is called 'sport' I should right {sport} in the groupHeaderTpl...
    I have changed it to {name} and it works of course.

    Sorry for wasting your time and thanks a lot, to both of you

Page 1 of 2 12 LastLast

Posting Permissions

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