-
9 Nov 2011 5:53 AM #1
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:
My column renderer: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 },
Any clue?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; },
Thank you!
-
Best Answer Posted by Dannesart
Thank you! Now it works!
needed to add a listener :and then an event:Code:this.store.on('load', this.onLoad, this);
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; }); },
-
9 Nov 2011 6:02 AM #2
Correction
Correction
Correction
Value1 (missingTimeReportWeeks)
value2 (nextPlannedActivitySubject)
-
9 Nov 2011 6:14 AM #3
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.
-
9 Nov 2011 7:00 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
I would filter the store to filter out the rows based on your criteria.
http://docs.sencha.com/ext-js/4-0/#!...ethod-filterByMitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
10 Nov 2011 1:40 AM #5
Example
Example
hmm, not sure how to use it. Could you make an example? would be awesome!
-
10 Nov 2011 2:10 AM #6Ext JS Premium Member
- Join Date
- Apr 2008
- Location
- Groningen - Netherlands
- Posts
- 1,017
- Vote Rating
- 23
- Answers
- 75
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; } });
-
10 Nov 2011 4:33 AM #7
Fixed
Fixed
Thank you! Now it works!
needed to add a listener :and then an event:Code:this.store.on('load', this.onLoad, this);
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; }); },


Reply With Quote