Remove all items from an array

Would suggest adding the ability to remove all items from an array element.

i always use this to empty an array, and this works for me:

of are you referring to something in the server actions?

This seems to be a simple solution, and very useful - but I can’t get it to work.

I created a few buttons to add numbers to an array. The array value is displayed on the page so I can see it’s working. I added another button including:
dmx-on:click="arr1.remove(arr1.items)"
… and it doesn’t do anything.

I can’t think what I could have missed.

Same here…originally tried this as well, but I can’t make it work.

@pheaxx Any ideas here?

@TomD @mebeingken My Apologies for the late answer.

so first, thank you for pointing this out, but you guys are right, it seems not to work. but i did found a solution, which is why it took some time to create an needed to implement with my projects.

what i now do it the following:

On the remove all button, i call a function like this:

onclick="values()"

and the function runs the following code:

  function values(){
  console.log(dmx.app.data.arr1.items);
  var a = dmx.app.data.arr1.items;
  a.forEach(function(entry) {
    console.log(entry);
    dmx.app.data.arr1.__removeAt(entry);
      
  });
}

just keep in mind that with big arrays this might take some time, maybe it's easier then to reload the page to dump the whole array. but i guess that would be the same with a native remove all function.

hope it helps.

Regards,

Nick

1 Like

Thanks Nick… Will use some JavaScript for now. I’m sure this operation will be added into the UI soon :slight_smile:

An empty method for the array component will be available in the next update

4 Likes

Hi @patrick

Will this be the next release?

Ray.

Yes, it was already added in the previous release, but it was missing on the UI.

1 Like