PDA

View Full Version : [CLOSED] TagField clears store filter after select.



CarlMGregory
Jun 17, 2016, 10:44 PM
Hello.

TagField appears to be clearing the stores filters after a user makes a section.
This makes sense since since, I'm assuming, it uses filters when typing in the TagField to narrow down your selection options.
However, this store already has a filter.
After the selection is made, ext clears all filters, not just the filter it used to narrow the selections when typing.
And, there is no trigger for after the filters are cleared so I can re-apply it.

Any ideas or suggestions?

The TagField:

<ext:TagField runat="server" StoreID="RecipientsStore" QueryMode="Local" DisplayField="Email" ValueField="Email" SelectOnTab="false" HideSelected="true">
<Listeners>
<BeforeQuery Handler="#{RecipientsStore}.filter({property:'EnterpriseCD' , value:#{EnterpriseComboBox}.value, id:'EnterpriseCD'});"></BeforeQuery>
</Listeners>
</ext:TagField>

This is the EXT JS code, the "me.store.clearFilter();" line is giving the headache.

onItemSelect : function (sm, record) {
var me = this;

if (me.ignoreSelection || !me.isExpanded) {
return;
}

me.inputEl.dom.value = "";

if (!me.createNewOnSelect) {
me.inputEl.dom.value = record.get(me.displayField);
if (me.collapseOnSelect !== false) {
me.collapse();
}

me.ignoreSelection++;
sm.deselect(record);
me.ignoreSelection--;
}
else {
me.addTagToInput(record);

if (me.collapseOnSelect === true) {
me.collapse();
}
}

me.fireEvent("select", me, record);
me.store.clearFilter();
me.inputEl.focus();
},

I could possibly fire on the firing on the select event with a 1ms delay, but this seems like a band-aid.

<ext:TagField runat="server" StoreID="RecipientsStore" QueryMode="Local" DisplayField="Email" ValueField="Email" SelectOnTab="false" HideSelected="true">
<Listeners>
<BeforeQuery Handler="#{RecipientsStore}.filter({property:'EnterpriseCD' , value:#{EnterpriseComboBox}.value, id:'EnterpriseCD'});"></BeforeQuery>
<Select Delay="1" Handler="#{RecipientsStore}.filter({property:'EnterpriseCD' , value:#{EnterpriseComboBox}.value, id:'EnterpriseCD'});"></Select>
</Listeners>
</ext:TagField>

Thanks.

fabricio.murta
Jun 19, 2016, 6:21 PM
Hello @CarlMGregory,

Please provide a simplified code sample demonstrating how to reproduce the issue.

The code sample you provide should include only the minimum amount of code required to reproduce the issue. Code unrelated to the issue is to be removed. Anyone should be able to copy + paste your sample into a local Visual Studio test project and run without having to make modifications.

Tips for creating simplified code samples (http://forums.ext.net/showthread.php?61176-Tips-for-creating-simplified-code-samples)

If Exceptions or syntax errors are thrown when testing your code sample, we'll let you know so you can revise your original sample. Then we'll review again with the updated sample.

When posting your code samples in the forums, please paste that sample within [CODE] tags. The [CODE] tags will add formatting and syntax highlighting to your sample.

The following two forum posts provide many excellent tips for posting in the forums:

1. More Information Required (http://forums.ext.net/showthread.php?10205-More-Information-Required)
2. Forum Guidelines (http://forums.ext.net/showthread.php?3440-Forum-Guidelines-For-Posting-New-Topics)

CarlMGregory
Jun 19, 2016, 8:14 PM
Hi, thanks for taking the time to respond.

The bulk of the code is above: http://forums.ext.net/showthread.php?61215-TagField-clears-store-filter-after-select&p=279115#post279115

Here is an example store you can use

var dataTable = new DataTable();
dataTable.Columns.Add("Email");
dataTable.Columns.Add("EnterpriseCD");
dataTable.Rows.Add("ABC123", "test@abc123.com");
dataTable.Rows.Add("ABC123", "test2@abc123.com");
dataTable.Rows.Add("ABC123", "test3@abc123.com");
dataTable.Rows.Add("EXT", "fabricio.murta@ext.net");

As my first post already outlines, step one, filter the store by something. In my case, as an example, filter EnterpriseCD by "ABC123". Now, trigger the drop down list for the TagField, you will see only 3 entries; test@abc123.com, test2@abc123.com, and test3@abc123.com. Click on any of those, such as the first, test@abc123.com. Now you will see the list change to test2@abc123.com, test3@abc123.com, and fabricio.murta@ext.net. (side note, test@abc123.com, what we clicked on, no longer is in the list because we are doing HideSelected="true", but this has nothing to do with the issue we are discussing, set it to false and that particular entry will not disappear, but still "fabricio.murta@ext.net" will appear, and that's the problem) If you open up the javascript console (f12) and query the filters on the store, the filter that is filtering it by EnterpriseCD is gone, there are no filters after a selection is made. And, again as I said above, this is because the 'onItemSelect''s second to last line clears all filters.

Here is a video showing the issue in action: https://db.tt/8nchm29l

Does that help, fabricio.murta?


Thanks.

fabricio.murta
Jun 20, 2016, 7:49 PM
Hello @CarlMGregory!

Indeed that video helps a lot, but we are still helpless without being able to actually run the code in our side, reproducing the issue as you show in the video, so we can fiddle in the guts of the JavaScript to give you a solution to the problem.

Simplifying the problem down to a few-lines-long single-code test case (and simple model+view+controller triple in MVC) is essential for us to be able to focus on the problem and help you out with it.

If you take your time over the threads linked above you'd understand. If you are using webforms, I am pretty sure you can simplify your example down to something even simpler than the GridFilters - Local example (http://examples2.ext.net/#/GridPanel/Plugins/GridFilters_Local/).