Hello:
it was previously from this issue raised here: https://ko.infragistics.com/community/forums/f/ignite-ui-for-angular/127165/how-to-programmatically-add-rows-to-a-datagrid-thru-button-click-without-reload?ReplySortBy=CreatedDate&ReplySortOrder=Ascending
However,
1) if i apply the filter, eg. go to Product-id and filter to show only "1"
2) click "Add new row", then it won't show it
3) until the filter is removed, eg. go to Product-id and select "All"
<igx-grid #grid [allowFiltering]="true" filterMode="excelStyleFilter" [data]="data" width="100%" height="500px" [primaryKey]="'ProductID'" [rowEditable]="true"
Any idea to by-pass this? Modified version: stackblitz.com/.../q2zkrdvm-rndm4osi
Hello Gan,
Thank you for contacting Infragistics Developer Support.
I have been looking into your question and the provided sample and what I can say is that this behavior is expected and is simply how filtered data works. If the grid is filtered by “ProductID” being equal to “1”, then in case the newly added row’s “ProductID” prop is not equal to “1”, it will not be shown in the data – it will get filtered out. This is the correct behavior.
To further demonstrate it, please, observe the following gif, where I have changed the “ProductID” column filter to “Contains”. At the moment the auto-incremented id contains “1”, it will be shown in the filtered data:
If you have any other questions regarding the IgxGrid usage, please, let me know.
Best regards,Bozhidara PachilovaSoftware Developer
hello:
I noticed some columns have the "(Blank)" option in the igx-excel-style-search, while some don't.
Is there any way, we could check-and-disable the option "(Blank)", so the new record could be shown always?
eg:
<ng-template igxExcelStyleFilterOperationsTemplate> <!-- ... other filter conditions ... --> <!-- Conditionally hide or disable "Empty" and "NotEmpty" options --> </ng-template>
or:
was trying to do something like this
this.grid?.filter('XXX', null, IgxStringFilteringOperand.instance().condition('contains'), true);
but it reloads all
Hi Gan,
To start with, the (Blanks) filter value is shown for any column having empty/blank values. By default, all filter values are checked, hence included in the grid. So, a newly added record with an empty value would be shown, unless the user had explicitly filtered the grid not to.
To address your question about altering the list of filter operations, sure this is possible. Please, check out this fork of your sample, where the “ProductName” column’s filters property is assigned to an instance of the IgxStringFilteringOperand class, whose operations array is modified not to include the “empty” and “notEmpty” IFilteringOperation objects:
public stringFilteringOperand; public constructor() { this.stringFilteringOperand = IgxStringFilteringOperand.instance(); this.stringFilteringOperand.operations = this.stringFilteringOperand.operations.filter( (op) => op.name !== 'empty' && op.name !== 'notEmpty' ); }
<igx-column field="ProductName" header="ProductName" [filters]="stringFilteringOperand" [dataType]="'string'" ></igx-column>
If you require any further assistance on the matter, please, let me know.
Thanks for the reply.
Think your example is not working when i changed the "ProductName" data, where ID = 2, to empty/null, from a fork from your example (https://stackblitz.com/edit/igx-grid-remove-empty-filtering-operands-esf-waau5qs6?file=src%2Fapp%2Fdata%2FnwindData.ts) :
{ ProductID: 2, ProductName: '', SupplierID: 1, CategoryID: 1, QuantityPerUnit: '24 - 12 oz bottles', UnitPrice: 19.0, UnitsInStock: 17, UnitsOnOrder: 40, ReorderLevel: 25, Discontinued: true, OrderDate: new Date('2003-03-17'), },,
It's not only still showing the "Blank", and when apply filter again, then the filter will keep showing loading icon
Hi Gan,iHi
The approach I shared removes the “Empty” and “Not empty” filter options from the Text filter list:
As mentioned, quoting:
“the (Blanks) filter value is shown for any column having empty/blank values. By default, all filter values are checked, hence included in the grid. So, a newly added record with an empty value would be shown, unless the user had explicitly filtered the grid not to.”
There is no built-in API exposed to remove this option, as it simply reflects any empty value. This is implemented as the Excel filtering, that is why the feature is named “Excel Style Filtering”.
Omitting this option would prevent users from filtering out such values, which might be a limiting factor.
Finally, I believe we need to clarify the expected requirement. Could you please, try to clarify what is that you are trying to achieve, since the current discussion has already deviated from the original thread topic. Do you need an initially applied / default condition that filter’s the Blanks values? Or is it something else?
Best regards,
Bozhidara Pachilova
user just want to see the newly added record to be visible when filter is on.
Do you need an initially applied / default condition that filter’s the Blanks values? Or is it something else?
Any workaround is fine, and can be proposed.
If the "(Blank)" filter can be programmatically selected, when button is clicked, is fine too, as long as newly added record is visible when filter is on.
Thank you for confirming the requirement. Now that this is clear, the previous approach to remove the “empty” filter options is not needed.
After further investigation, what I can say, which to an extent repeats my initial reply to your question, is that this behavior, is simply intrinsic to the filtering functionality. If the user has filtered out certain values, regardless of them being empty or not, even newly added records would participate in the filtering. Furthermore, overriding any user-set filters may be an unsatisfactory experience, since filtering is in the control of the user, after all.
Any workaround here could be error prone having in mind that the IgxGrid does not expose an API for this specifically, and again, programmatically overriding user filters at the point of adding a row is simply unexpected from a user’s perspective.
The logic that determines whether or not to display the “Show” action in the toast is specifically implemented with this in mind – there would be nothing to scroll to, if the record is not in the view.
In conclusion, any user that has intentionally entered an empty value for a column and has prior to that filtered out empty values, must expect not to see the record until the filter is cleared by them.