lorenzofox3 / Smart-Table

Code source of Smart Table module: a table/grid for Angularjs
http://lorenzofox3.github.io/smart-table-website/
1.8k stars 513 forks source link

st-descending-first only support "true" #814

Closed mdarveau closed 6 years ago

mdarveau commented 6 years ago

Angular 1.6.4 Smart-table 2.1.9

Hi,

The st-descending-first attribute does not accept the value false. The descending first behavior is activated on the presence of the attribute and the value itself does not matter. Maybe this is by design, but it was unexpected.

In my case, ordering is dynamic as columns are generated from an array and some columns should descending first while other shouldn't. I tried to st-descending-first="{{col.sort=='DESC'?true:false}}" and the descending first was always applied.

If anyone has the same issue, there is a workaround using ng-attr-st-descending-first="{{col.sort=='DESC'?true:undefined}}"

Feel free to close if this is the expected behavior. Also worth noting that st-descending-first is not documented.

lorenzofox3 commented 6 years ago

I actually wish to align the behavior to regular HTML boolean attributes

It implies indeed that my-attribute="whatever" (could be true or false) should be considered as "true"

mdarveau commented 6 years ago

I still find this to be counter-intuitive in the context of angular/dynamic binding of properties, but I respect that this is a design decision. Thanks!