-
24 Jan 2013 1:21 AM #1
Unanswered: Disable empty text / panel on NestedList
Unanswered: Disable empty text / panel on NestedList
My situation is that we have a nested list which contains a text (search) field at the top. This field is used for filtering purposes of the items collection of the nested list. The field is also present in the list's items collection.
The problem is here that when there are no matches / results the store bound to the nested list does not return any results. This is perfectly OK, but the problem is that the list automatically shows the "empty text template". And because of that the text (search) field is hidden and thus the filter text cannot be changed/cleared for the list to 'repopulate'.
I tried setting the emptyText field to '' or null but that does not prevent the nested list items collection to be kind of hidden. Basically I do not want any empty text / layer to be displayed when the store does not return any result, my fixed field (first item in the items collection I guess) should stay visible so the user can clear the filter.
-
24 Jan 2013 5:20 AM #2
Try this
Try this
Did you try to set:
deferEmptyText: false
Alternative:
Add an empty item to the store and make sure this is always true to any search.
if so the record length is larger 0
Alternative 2:
if all this does not work for you try to hide the empty text component:
list.emptyTextCmp.hide()
-
24 Jan 2013 9:31 AM #3
I tried this, but this solution only seems to prevent the text to be shown untill the store is loaded for the first time (as expected).
Well, actually I only take this approach / workaround when there is really no other option left. I would rather disable the component/layer showing the empty text.
Thanks for making me aware of the existence of this component. The only thing is that this property does not seem to be available on a NestedList. I did some digging and this property is declared on the DataView class from which a normal List inherits, but the NestedList does not. Thus I was not able to find anything related to 'emptyTextCmp' in combination with a NestedList. Perhaps you/somebody else knows more about that?
-
24 Jan 2013 10:47 AM #4
So I guess you have to make from the following code, what you need:
You code write a listener for the emptyTextCmp to act on show.Code:if (this.getEmptyText() && (this.hasLoadedStore || !this.getDeferEmptyText()) ) { this.emptyTextCmp.show(); }
Or if not available the corresponding item with a listener like:
Code:listeners: { show: { element: 'emptyTextCmp' // you need to find out the name of the actual item fn: function() {} }
-
24 Jan 2013 11:11 AM #5
Good idea, but I am really unable to find anything related to "emptyText". I checked all the source code files from NestedList.js till the base class definition. I must overlook something since it has to be in one of the files. Perhaps a developer can point me in the right direction? I am really overlooking something here I have the feeling.
-
24 Jan 2013 4:19 PM #6
Please provide more information. How about the nested list and the filter you are applying.
-
30 Jan 2013 3:44 PM #7
Well I tried to create a fiddle, but that's kinda difficult with server-side filtering and custom controls. Basically I have a NestedList, and the only thing I do is specifing a searchfield (xtype) in the .Items collection of that NestedList.
Using a controller I watch the key events on that field, and with postbacks (via a TreeStore) I perform filtering server-side. Point is that when zero results are returned from the store, a mechanism triggers this emptyText layer/component thingy which hides the items collection of the list. Normally this would be OK, but this time not since I want that searchfield to remain visible.
A 'normal' list has the emptyTextCmp, but a NestedList not? Weird though, since there must be something hiding my searchfield.
-
31 Jan 2013 3:45 AM #8
Ahh ok. So you refil the store via proxy and you have an empty store.
I'll check on that one later.
-
31 Jan 2013 4:22 PM #9
-
4 Feb 2013 4:01 AM #10
Hi there,
I asked for some code to be able to reproduce your problem.
As you did not post anything, its hard to help you.
Here is a setting I tried, but without success:
The searchfield is not shown with/without data.Code:Ext.define('ListItem', { extend: 'Ext.data.Model', config: { fields: [{ name: 'text', type: 'string' }] } }); data = {/* fill with a long list of data */}; // data = {}; //Use this to an empty data var store = Ext.create('Ext.data.TreeStore', { model: 'ListItem', storeId: 'Metro', defaultRootProperty: 'items', root: data }); var searchfield = { xtype: 'searchfield', label: 'TryMe', query: 'query', height: 50, width: '100%', style: 'background-image: none; background-color: red;' }; var nestedList = { xtype: 'nestedlist', title: 'Groceries', displayField: 'text', store: store, items: searchfield }; this.add(nestedList);
Please post some code or otherwise there is no way helping you.


Reply With Quote