Skip to content
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-search on select tag not working on initial value #819

Open
IngoVals opened this issue Jan 5, 2018 · 1 comment
Open

st-search on select tag not working on initial value #819

IngoVals opened this issue Jan 5, 2018 · 1 comment

Comments

@IngoVals
Copy link

IngoVals commented Jan 5, 2018

I'm using a select as a filter for a Smart-table. It is a simple filter and shows rows based on status. The initial value of the filter should show rows that have status Active but it seems that st-search doesn't get implemented until the first time it is changed, so on initial load no filtering is done.

Is it something I'm doing wrong or is there a simple workaround I'm missing?

See this plunker for an example of this

    <select st-search="status" st-delay="0">
      <option ng-repeat="f in statusOptions" ng-selected="f.code == 'Active'"
                    value="{{f.code}}">{{f.text}}</option>
    </select>
    <table>
      <thead>
        <tr>
          <th>Name</th>
          <th>Status</th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="row in collection | orderBy: 'status'">
          <td>{{row.name}}</td>
          <td>{{row.status}}</td>
        </tr>
      </tbody>
    </table>
  </section>
$scope.statusOptions = [
  { 'text': 'Everything', 'code': ''},
  { 'text': 'Active', 'code': 'Active' },
  { 'text': 'Cancelled', 'code': 'Cancelled'},
  { 'text': 'Expired','code': 'Expired' },
  { 'text': 'Waiting', 'code': 'Waiting'}
]

Using angular 1.6.4
Smart-table 2.1.8

@lorenzofox3
Copy link
Owner

It seems that the value of option set with ng-selected does not trigger the input or change event in the first place. You could wrap you select in its own directive and make set the initial value so the event is triggered

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

No branches or pull requests

2 participants