Refresh iron-data-table

428 views Asked by At

I'm using iron-data-table loaded with JSON data from iron-ajax. I let the user select multiple lines and click "delete". The list is sent to the backend and is deleted from the database.

<iron-ajax url="/data/ban" last-response="{{users}}" auto></iron-ajax>
         <iron-data-table selection-enabled multi-selection id="banTable"
        items="[[users]]">


handleTap: function() {
      var table = this.$$('#banTable');
      $.ajax({
          type: "POST",
          url: "/ban/remove?_csrf=" + this.token,
          data: JSON.stringify(table.selectedItems),
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function (msg) {
              if (msg) {
                  table.clearCache();
              } else {
                  alert("Cannot update list !");
              }
          }
      });

However on the front-end, the table is not updated. I tried table.clearCache but it does not help.

Any idea on how to proceed ?

1

There are 1 answers

2
Shirin Safaeian On BEST ANSWER

Add some id to your iron-ajax and in your success function call its generateRequest() function:

This.$.myAjax.generateRequest()

This will referesh users array