Results 1 to 6 of 6

Thread: How to get groupField value after Grouping is change

  1. #1
    Sencha User
    Join Date
    Aug 2011
    Location
    India
    Posts
    180
    Answers
    1

    Default Answered: How to get groupField value after Grouping is change

    Hi All,
    I am using Grouping feature of the ExtJs. I want to delete on Right click the total Group.
    I am able to find out.

    In the below code I have marked in bold 'Customer' , currently I have put this hardcoded value.

    It is possible that I will get the current's value after grouping changed?
    Can you please guid?

    Like in the below data, Default groupField= Customer, when I change to OrderPrice then i should get the Orderprice so something , so that I will be able to delete the whole group.

    Please suggest if any other solution...
    Store data
    Code:
                           {Customer:'CustomerA',OrderPrice:'2000',ProductCode:'AABBDCCEE'},
                    {Customer:'CustomerA',OrderPrice:'1000',ProductCode:'AABBDCCEEDD'},
                    {Customer:'CustomerA',OrderPrice:'3000',ProductCode:'AABBDCCEEDD'},
                    {Customer:'CustomerB',OrderPrice:'4000',ProductCode:'AABBDCCEE'},
    Menu code :-
    Code:
    groupcontextmenu:function (view,node,group,e,eOpts)
                            {
                                
                            var menu= new Ext.menu.Menu();
                            menu.add({text:"Edit",icon: 'css/images/add16.gif',handler:
                                    function()
                                        {
                                            
                                            //var my_record = view.getSelectionMode() ;
                                            alert(value)
                                            /*var my_record_param = 'name='+my_record.data['name']+'&group='+group;
                                            var my_url = 'Test.jsp?' + my_record_param
                                            new Ext.Window({
                                                      width: 500,
                                                      title:'New redirected window',
                                                      resizable :true,
                                                      minimizable :true,
                                                      height: 500,
                                                      closable: true,
                                                      html: '<iframe width="500" height="500" src="' + my_url + '"</iframe>'
                                                      }).show();
                                                */
    
    
                                        }
                                      });
                            menu.add({text:"Delete Record",handler://RowDelete(grid)
                                    function()
                                         {
                                             alert(group)
                                             var values= RestaurantStore.queryBy(function(record)
                                                 {
                                                     return record.get('Customer')==group
                                                 })
                                                 
                                             for(var i = 0, len = values.length; i < len; i++)
                                                 {  
                                                    RestaurantStore.remove(values.getAt(i));        
                                                }  
                                         } 
                                    });
                            e.stopEvent();
                            menu.showAt(e.xy);
                                    
                            }

    Extjs Grouping feature:-

    Code:
       var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
            groupHeaderTpl: '{name} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})'
            //startCollapsed:true
        });

  2. Hey Thanks a lot.. I was looking for this only

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    The groupField property of the store perhaps?

    http://docs.sencha.com/ext-js/4-0/#!...rty-groupField

  4. #3
    Sencha User
    Join Date
    Aug 2011
    Location
    India
    Posts
    180
    Answers
    1

    Default

    Thanks for the reply.
    The Group Field property returns the value that we have specified in the Store. i.e. default grouping.
    But I want the value after the Grouping is changed.

    Like When I define the store , the code is

    Code:
     
    
    var RestaurantStore = Ext.create('Ext.data.JsonStore', {
            storeId: 'restaraunts',
            model: 'Restaurant',
            sorters:['ProductCode','OrderPrice','Customer'],
            groupField: 'Customer',
            data:[
                    {Customer:'CustomerA',OrderPrice:'2000',ProductCode:'AABBDCCEE'},
                    {Customer:'CustomerA',OrderPrice:'1000',ProductCode:'AABBDCCEEDD'},
                    {Customer:'CustomerA',OrderPrice:'3000',ProductCode:'AABBDCCEEDD'},
                    {Customer:'CustomerB',OrderPrice:'4000',ProductCode:'AABBDCCEE'},
                    {Customer:'CustomerB',OrderPrice:'4000',ProductCode:'AABBDCCEEFF'},
                    {Customer:'CustomerB',OrderPrice:'2000',ProductCode:'AABBDCCEEFF'},
                    {Customer:'CustomerC',OrderPrice:'2000',ProductCode:'AABBDCCEE'},
                    {Customer:'CustomerC',OrderPrice:'3000',ProductCode:'AABBDCCEEGG'},
                    
            ]
        });
    In the above code my default Grouping will be on "Customer" column.

    But I want if I regroup my Grid using say "ProductCode" [like in the given example ]

    How will I get the Newly GroupField value i.e. "ProductCode" ??


    Hope I am able to explain my query very well.

    GroupField_AfterGroupChange.jpg

  5. #4
    Sencha Premium User twaindev's Avatar
    Join Date
    Sep 2009
    Posts
    242
    Answers
    16

    Default

    Perhaps you can use the groupchange event of the store?

    http://docs.sencha.com/ext-js/4-0/#!...nt-groupchange

  6. #5
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    The Group Field property returns the value that we have specified in the Store. i.e. default grouping.
    But I want the value after the Grouping is changed.
    Agreed. I suspect there's a mistake in the docs and that property should actually be listed as a config option instead.

    Seems you can get the grouper using:

    Code:
    store.groupers.first();
    If you want the field name it would be:

    Code:
    store.groupers.first().property;

  7. #6
    Sencha User
    Join Date
    Aug 2011
    Location
    India
    Posts
    180
    Answers
    1

    Default

    Hey Thanks a lot.. I was looking for this only

Posting Permissions

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