bluewatertracks / bwt-datatable

Data table with Polymer 3 support!
GNU General Public License v3.0
42 stars 14 forks source link

Simple filter not working #26

Closed chavu closed 6 years ago

chavu commented 7 years ago

I'm trying to implement a simple filter but I can't get it to work. below is my code snippets


  <template>

    <cuba-query id="data"
        entity-name="myApp$myEntity"
        query-name="myQuery"
        params="{{queryParams}}"
        data="{{entities}}"
        loading="{{dataLoading}}"
        provide-count="true"
        count="[[entitiesCount]]"
        auto="[[active]]"
        handle-as="json">
    </cuba-query>

    <iron-ajax auto url="data.json" last-response="{{entities}}"></iron-ajax>

    <div >
        Search:  <paper-input value="{{filterString}}" style="display:inline-block;" label="Team name" on-input="applyFilter" ></paper-input>
    </div> 

    <paper-datatable id="datatable" data="[[entities]]" filter="{{tableFilter}}" >

        <paper-datatable-column  header="Home Team" property="description" type="String" sortable>
        <template>
            <span>{{value}}</span>
        </template>
        </paper-datatable-column>

    </paper-datatable>

  </template>

 <script>
    Polymer({
        is: 'app',
        behaviors: [CubaLocalizeBehavior, CubaEntityListViewBehavior ,CubaAppAwareBehavior],
        properties: {

            filterString: {
                type:String,
                value:''
            },

        },

        tableFilter: function(item, key, items){
            return item.description = (this.filterString || '');
        },

        applyFilter: function(){
                this.$.datatable.reload();
        }, 

    });
  </script>
dhrytsenko commented 7 years ago

Your filter function must return true or false value to filter some elements inside your data array. Check please filter demo

chavu commented 7 years ago

I am using that filter demo. It appears the filter function is not even being called. Only the applyFilter function is being called. I tested this by putting a debug.log(); statement or by putting a break using Chrome's debuger tool. I also tried just putting a return false; statement only inside the filter function hoping no rows would be displayed but still all rows are dispalyed.

dhrytsenko commented 6 years ago

Closed due to inactivity. You can open it again if still have this problem