Jump to content

TUniDBGrid - Grouping - Text of group-header


erich.wanker

Recommended Posts

HI,

in a table - i have a lot of persons - and 50% are in different categories - 50% are in no category  (must be a empty database field !!)

i use TUniDBGrid - Grouping with Fieldname "category-Name" and FieldCapture "Category-Name" 

Works fine ! :-)

BUT: I want change the caption of group header to "Persons without Categories" if the "category-Name" is empty ???

 

Actual i have a uniDBGrid like this

+   Category-Name:                                                               <- here are all Records without Category 
+   Category-Name:  FisteCategoryDescription
+   Category-Name:  SecondCategoryDescription  
+   Category-Name:  and so on ...

 

I want a uniDBGrid like this

+   Persons without Categories  
+   Category-Name:  FisteCategoryDescription
+   Category-Name:  SecondCategoryDescription  
+   Category-Name:  and so on ...

 

ThanX

Erich

Link to comment
Share on other sites

function beforeInit(sender, config)
{ 
 config.groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
   groupHeaderTpl:new Ext.XTemplate('{[this.getGroupTitle(values.rows[0])]}',
    {
      getGroupTitle: function(values) {
             if(values.data[1]=='') 
              return 'My custom title: '+values.data[8];/*<--[8]field index*/
             else 
              return 'Other title: '+values.data[2];/*<--[2]field index*/
        }
     })   
  });  
  config.features= [config.groupingFeature];
 }

 Grid->Unievents

I already explained that in one of my videos :-)

  • Upvote 1
Link to comment
Share on other sites

WOW .. THANX a lot :-) ... works perfect !!!!

 

i stored it in "onFrameCreate" and search the right index number 

gruppenname_id:='0';
cnt := Mydbgrid.Columns.Count;
        for colIdx := 0 to cnt - 1 do
          begin
            if Mydbgrid.Columns[colIdx].FieldName = 'gruppenname' then gruppenname_id:= inttostr(colIdx);
          end;


Mydbgrid.ClientEvents.UniEvents.Add('beforeInit=function beforeInit(sender, config)'+
'{ '+
' config.groupingFeature = Ext.create('+#39+'Ext.grid.feature.Grouping'+#39+',{ '+
'   groupHeaderTpl:new Ext.XTemplate('+#39+'{[this.getGroupTitle(values.rows[0])]}'+#39+','+
'    { '+
'      getGroupTitle: function(values) {'+
'             if(values.data['+gruppenname_id+']=='+#39+''+#39+')'+
'              return '+#39+'All the ungroupt Things are here :-) '+#39+';'+
'            else '+
'              return '+#39+'Gruppenname: '+#39+'+values.data['+gruppenname_id+']; '+
'        } '+
'     })'+
'  });'+
'  config.features= [config.groupingFeature]; '+
' } ');

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...