Skip to content
This repository has been archived by the owner on Apr 2, 2019. It is now read-only.

[Feature Request] Allow emptyText to be a function #332

Closed
toekneestuck opened this issue Aug 30, 2013 · 2 comments
Closed

[Feature Request] Allow emptyText to be a function #332

toekneestuck opened this issue Aug 30, 2013 · 2 comments
Milestone

Comments

@toekneestuck
Copy link

Allowing emptyText to be a function is useful if you are dealing with searching/filtering and want to display a different "message" when no results are returned. I want to be able to display different messaging based on whether a user has no items in a particular collection versus finding no results when filtering or searching within a collection.

I think adding javascript _.result(this, 'emptyText') on line 67 in body.js would solve this problem and allow the logic to be executed whenever the empty row is shown.

As example function for emptyText may look like this:

emptyText : function(){
    return this.collection.isSearching() ? 'No results found.' : 'You have no records'; 
}

For more context, I've extended Backbone.Pageable to implement searching and filtering in client/server/infinite modes, so figured I would recommend this enhancement for others that might be in the same boat.

@wyuenho
Copy link
Contributor

wyuenho commented Aug 31, 2013

Mmmm. What do you think about this feature in relation to #173 ?

@toekneestuck
Copy link
Author

@wyuenho Interesting. I think they're related, but a little different. I like the suggestions in #173 to simply tap into the collection events (request/sync/error) to display loading animations. I don't think a feature like that should necessarily be built into Backgrid, as the placement/implementation of a spinner can vary depending on your project.

To solve both this issue and some requests in #173, I might recommend allowing the EmptyRow to be passed in to a new instance of Backgrid.Grid (and also pass along the collection to the empty row view, so messaging/display can reflect the current state). Might also make sense to make the empty row a property of Backgrid.Body, so overriding/extending is easy?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants