1. #1
    Ext JS Premium Member
    Join Date
    Aug 2011
    Location
    Sweden
    Posts
    31
    Answers
    2
    Vote Rating
    0
    Dannesart is on a distinguished road

      0  

    Default Answered: remove row if value1 is 0 and value2 is null

    Answered: remove row if value1 is 0 and value2 is null


    Hi! I want to remove a row in a grid if value1= 0 and value2= null.

    This is my columns:
    Code:
    {
                    xtype: 'gridcolumn',
                    header: IPtranslate('Intelliplan.Common.Grid.PlannedActivitySubjectColumn.Header'),
                    width: 100,
                    dataIndex: 'nextPlannedActivitySubject',
                    sortable: true,
                    renderer: Intelliplan.Common.General.ColumnRenderers.nextPlannedActivity
                },
                {
                    xtype: 'gridcolumn',
                    header: IPtranslate('Intelliplan.Common.Grid.MissingTimeReportsColumn.Header'),
                    width: 70,
                    dataIndex: 'missingTimeReportWeeks',
                    sortable: true,
                    align: 'center',
                    renderer: Intelliplan.Common.General.ColumnRenderers.missingTimeReports
                },
    My column renderer:
    Code:
       nextPlannedActivity: function(value, metaData, record, rowIndex, colIndex, store, view) {
                if (value) {
                    var tooltipTitle;
                    var activityTime = Ext.Date.format(record.get('nextPlannedActivityTime'), Intelliplan.Formats.date.shortDate);
                    if (record.get('nextActivityOverdue') && record.get('nextPlannedActivitySubject')) {
                        tooltipTitle = IPtranslate('Intelliplan.Common.Grid.NextPlannedActivityColumn.OverdueTooltipTitle') + ' ' + activityTime;
                        metaData.tdAttr = Intelliplan.Util.Qtip.createInvalidAttrString(value, tooltipTitle, 250);
                        return Intelliplan.Common.General.GridTemplates.overdueActivityColumn.applyTemplate(
                            {
                                activityNo: record.get('nextPlannedActivityNo'),
                                value: value
                            });
                    }
                    tooltipTitle = IPtranslate('Intelliplan.Common.Grid.NextPlannedActivityColumn.TooltipTitle') + ' ' + activityTime;
                    metaData.tdAttr = Intelliplan.Util.Qtip.createAttrString(value, tooltipTitle);
                    return Intelliplan.Common.General.GridTemplates.activityColumn.applyTemplate(
                        {
                            activityNo: record.get('nextPlannedActivityNo'),
                            value: value
                        });
                }
                return value;
            },
    
     missingTimeReports: function(value, metaData, record, rowIndex, colIndex, store, view) {
                var timeReportDate, missingTimeReportWeeksTooltip, bossHasTimeReportsTooltip;
                if (record.get('missingTimeReportWeeks') > 0 || record.get('bossHasTimeReports')) {
                    timeReportDate = Ext.Date.format(record.get('timeReportDate'), 'Y-m-d');
                    missingTimeReportWeeksTooltip = Ext.String.format(IPtranslate('Intelliplan.Common.Grid.MissingTimeReportsColumn.MissingTimeReportWeeksTooltip'), record.get('missingTimeReportWeeks'));
                    bossHasTimeReportsTooltip = IPtranslate('Intelliplan.Common.Grid.MissingTimeReportsColumn.BossHasTimeReportsTooltip');
                    return Intelliplan.Common.General.GridTemplates.missingTimeReportsColumn.applyTemplate(
                        {
                            empNo: record.get('empNo'),
                            custOrderNo: record.get('custOrderNo'),
                            timeReportDate: timeReportDate,
                            missingTimeReportWeeks: record.get('missingTimeReportWeeks'),
                            missingTimeReportWeeksTooltip: Intelliplan.Util.Qtip.createAttrString(missingTimeReportWeeksTooltip),
                            bossHasTimeReports: record.get('bossHasTimeReports'),
                            bossHasTimeReportsTooltip: Intelliplan.Util.Qtip.createAttrString(bossHasTimeReportsTooltip)
                        }
                    );
                }
    
                return null;
    
            },
    Any clue?

    Thank you!

  2. Thank you! Now it works!

    needed to add a listener :
    Code:
    this.store.on('load', this.onLoad, this);
    and then an event:
    Code:
     onLoad: function(store, records, successful, operation, options) {
             this.getStore().filterBy(function(record) {
    
                if (record.get('missingTimeReportWeeks') === 0 && Ext.isEmpty(record.get('nextPlannedActivitySubject'))) {
                    return false;
                    console.log(record.get('missingTimeReportWeeks'));
                }
    
                return true;
            });
        },

  3. #2
    Ext JS Premium Member
    Join Date
    Aug 2011
    Location
    Sweden
    Posts
    31
    Answers
    2
    Vote Rating
    0
    Dannesart is on a distinguished road

      0  

    Default Correction

    Correction


    Correction
    Value1 (missingTimeReportWeeks)
    value2 (nextPlannedActivitySubject)

  4. #3
    Ext JS Premium Member
    Join Date
    Aug 2011
    Location
    Sweden
    Posts
    31
    Answers
    2
    Vote Rating
    0
    Dannesart is on a distinguished road

      0  

    Default Image example

    Image example


    awddfw.jpg

    so under the column Planerad aktivitet (nextPlannedActivity) the value is equal 0 that's why there is no value in the cell. same for Tidrapport(missingTimeReports) the "value" is null so that's why there is no clock icon in the cell. So what I want is that if nextPlannedActivity is 0 and missingTimeReports is Null the row person2 souldn't be rendered.

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,327
    Answers
    3540
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I would filter the store to filter out the rows based on your criteria.

    http://docs.sencha.com/ext-js/4-0/#!...ethod-filterBy
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  6. #5
    Ext JS Premium Member
    Join Date
    Aug 2011
    Location
    Sweden
    Posts
    31
    Answers
    2
    Vote Rating
    0
    Dannesart is on a distinguished road

      0  

    Default Example

    Example


    hmm, not sure how to use it. Could you make an example? would be awesome!

  7. #6
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,118
    Answers
    85
    Vote Rating
    30
    tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about

      0  

    Default


    Code:
    store.filterBy(function(r, id) {
    
            //r is a model, id record passed
            
            if (r.data['value1'] == 0 && r.data['value2'] == null) {
                 return false;   
            }
        
           return true;
        }
    });

  8. #7
    Ext JS Premium Member
    Join Date
    Aug 2011
    Location
    Sweden
    Posts
    31
    Answers
    2
    Vote Rating
    0
    Dannesart is on a distinguished road

      0  

    Default Fixed

    Fixed


    Thank you! Now it works!

    needed to add a listener :
    Code:
    this.store.on('load', this.onLoad, this);
    and then an event:
    Code:
     onLoad: function(store, records, successful, operation, options) {
             this.getStore().filterBy(function(record) {
    
                if (record.get('missingTimeReportWeeks') === 0 && Ext.isEmpty(record.get('nextPlannedActivitySubject'))) {
                    return false;
                    console.log(record.get('missingTimeReportWeeks'));
                }
    
                return true;
            });
        },

Thread Participants: 2