-
Notifications
You must be signed in to change notification settings - Fork 515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
st-sort should treat null, undefined, and emtpy strings consistently. #669
Comments
Have exactly the same problem, I would like empty object to be put at the top regardless of sorting :( |
Is there any update here? |
Anyworkarounds at least? |
Nothing? |
I have similar (but not the same) problem. I need only rows where certain value is empty (null or undefined). Here is my code: <table st-table="$ctrl.displayedCollection" st-safe-src="$ctrl.stories.all" class="table table-hover ">
<thead>
<tr>
<th colspan="1">
<input st-search="title" class="form-control" placeholder="Search by title" type="text">
</th>
<th colspan="1">
<select st-search="assignee.name" st-input-event="change" class="form-control"
placeholder="author">
<option value="" selected>Select assignee</option>
<option value="???">unassigned</option>
<option ng-repeat="user in $ctrl.users.all">{{user.name}}</option>
</select>
</th>
<th colspan="1">
<select st-search="stage" st-input-event="change" class="form-control"
placeholder="stage">
<option value="" disabled selected>Select stage</option>
<option ng-repeat="stage in $ctrl.stories.stages">{{stage}}</option>
</select>
</th>
<th st-sort="created_at">Sort by age</th>
<th st-sort="deadline_at">Sort by deadline</th>
<th>
<button class="btn btn-success" ui-sref="createStory">New story</button>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in $ctrl.displayedCollection">
<td><a ui-sref="story({ _id: row._id })">{{::row.title}}</a></td>
<td>{{::row.assignee.name}}</td>
<td>{{::row.stage}}</td>
<td am-time-ago="row.created_at"></td>
<td am-time-ago="row.deadline_at"></td>
<td><span class="glyphicon glyphicon-remove-sign story-grid--remove-btn"></span></td>
</tr>
</tbody>
</table> Problem is with the field "assignee". If I set option value to "" it filters nothing. Expected behaviour is to filter out all but empty rows. |
I'd like to see null, undefined, and empty strings be treated consistently as well. In my case, I'd prefer to have them sorted at the bottom rather than the top. |
Is there any work around for this issue? as @tdharris suggested, seeing the empty strings at bottom would make more sense |
In my case, I want empty object to be put at the top, to show as most recent entries.. whats the solution? |
A solution to all of your issues would be to replace default angular orderBy filter by your own if you are not happy with its behavior. (cf #176) In some cases it might just be a simple wrapper around the default one providing the third argument (comparator) which is not forwarded by smart-table module.filter('customSort', ['orderBy',function customSort(orderBy){
const customComp = () => {} //a custom comparator function you want to pass to orderBy
return function customOrder ( array,predicate,direction){
return orderBy(array,predicate,direction,customComp);
}
} |
When sorting rows based on model values via st-sort, currently empty strings are treated as smallest, undefined is treated as largest, and null is converted to the string "null" (ie. falls between "nukk" and "numm")
As all 3 are rendered into the DOM visually as an empty string, I feel the sort should be consistent and place all 3 at the start/end.
Latest version of smart table (2.1.8)
Recent version of angular (1.5.3)
http://plnkr.co/edit/BEBdzWI44z3BiIxRRDET?p=preview
The text was updated successfully, but these errors were encountered: