PDA

View Full Version : remove row if value1 is 0 and value2 is null



Dannesart
9 Nov 2011, 5:53 AM
Hi! I want to remove a row in a grid if value1= 0 and value2= null.

This is my columns:

{
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:

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!

Dannesart
9 Nov 2011, 6:02 AM
Correction
Value1 (missingTimeReportWeeks)
value2 (nextPlannedActivitySubject)

Dannesart
9 Nov 2011, 6:14 AM
29175

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.

mitchellsimoens
9 Nov 2011, 7:00 AM
I would filter the store to filter out the rows based on your criteria.

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Store-method-filterBy

Dannesart
10 Nov 2011, 1:40 AM
hmm, not sure how to use it. Could you make an example? would be awesome!

tvanzoelen
10 Nov 2011, 2:10 AM
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;
}
});

Dannesart
10 Nov 2011, 4:33 AM
Thank you! Now it works!

needed to add a listener :
this.store.on('load', this.onLoad, this);

and then an event:


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;
});
},