Jump to content

Grid Grouping showvalue date format, how to use DD/MM/YYYY


FFREDIANELLI

Recommended Posts

Hi Sherzod

No code involved, i just enabled grouping , summary and show value, the title i let the name of the field..., iin the dbgrid, and thats it... it shows the header of grouping followed by the date correclty , but the format not follow the datasource display format , and i do not find any display format in this grouping opptions, it shows in gmt format...

 

Link to comment
Share on other sites

4 hours ago, FFREDIANELLI said:

No code involved, i just enabled grouping , summary and show value, the title i let the name of the field..., iin the dbgrid, and thats it... it shows the header of grouping followed by the date correclty , but the format not follow the datasource display format , and i do not find any display format in this grouping opptions, it shows in gmt format...

Ok. Try searching the forum with the keyword "groupheadertpl".

Link to comment
Share on other sites

  • 3 weeks later...

ok, there are some examples to show how to put qtd of items in the group header, some text explaining the group, but none of how to show a date header in DD/MM/YYYY

i found this javascript function 

function format(inputDate) {
  let date, month, year;

  date = inputDate.getDate();
  month = inputDate.getMonth() + 1;
  year = inputDate.getFullYear();

    date = date
        .toString()
        .padStart(2, '0');

    month = month
        .toString()
        .padStart(2, '0');

  return `${date}/${month}/${year}`;
}
 

but how to adapt this function , that now show the qtd items (cool) but with the date in DD/MM/YYYY format ?

function beforeInit(sender, config)
{
  sender.disableSelection = true;
    var groupingFeature = Ext.create('Ext.grid.feature.Grouping', {
        groupHeaderTpl: new Ext.XTemplate(
            '{columnName}: {name} ({[this.countTotal(values.rows)]})',
            '', {
                countTotal: function(records) {
                    var totalSum = 0;
                    totalSum = records.length;
                    return totalSum;
                }
            }
        ),
        hideGroupedHeader: true
    });
    config.features = [groupingFeature]
}
 

Some help will be appreciated , thenks in advance.

Date.png

Link to comment
Share on other sites

2 hours ago, FFREDIANELLI said:

Some help will be appreciated , thenks in advance.

Date.png

Try this approach:

function beforeInit(sender, config)
{
    var groupingFeature = Ext.create('Ext.grid.feature.Grouping', {
        groupHeaderTpl: new Ext.XTemplate(
            '{columnName}: {[this.toDMY(values)]} ({[this.countTotal(values.rows)]})',
            '', {
                countTotal: function(records) {
                    var totalSum = 0;
                    totalSum = records.length;
                    return totalSum;
                },
                toDMY: function(value) {
                    return Ext.Date.format(value.renderedGroupValue, "d/m/Y");
                }
            }
        ),
        hideGroupedHeader: true
    });
    config.features = [groupingFeature]
}

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...