how to remove elemenst from ArrayDataProvider

140 views
Skip to first unread message

Kavita Jain

unread,
May 27, 2020, 4:38:50 AM5/27/20
to KnockoutJS
I have an observable array and  from this observable array, constructing an dataArrayProvider. how can i empty this dataArrayprovider.

For eg.
self.x = ko.observableArray([]);
//updating x with some vales say {4 5 6 }
self.y = new ArrayDataProvider(self.x, { keyAttributes: "id" });

later, I m clearing this observable array
x.removeAll();

but I dont know how to clear data for ArrayDataProvider. plz help out.
Thanks

jks...@jkshay.com

unread,
May 27, 2020, 4:52:42 AM5/27/20
to knock...@googlegroups.com
Try making your self.y a KnockoutComputed type? It will be based on self.x values and update automatically when self.x changes.

Sent from my iPhone

On May 27, 2020, at 4:39 AM, Kavita Jain <kv1...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/knockoutjs/81056374-018e-4507-9d80-03b15595b131%40googlegroups.com.
Message has been deleted

Kavita Jain

unread,
May 27, 2020, 5:37:10 AM5/27/20
to KnockoutJS

Can u give me the syntax for the same, as I am not aware how to make arraydata provider with particular index to computed one.

Thanks


On Wednesday, May 27, 2020 at 2:22:42 PM UTC+5:30, jks...@jkshay.com wrote:
Try making your self.y a KnockoutComputed type? It will be based on self.x values and update automatically when self.x changes.

Sent from my iPhone

On May 27, 2020, at 4:39 AM, Kavita Jain <kv1...@gmail.com> wrote:


I have an observable array and  from this observable array, constructing an dataArrayProvider. how can i empty this dataArrayprovider.

For eg.
self.x = ko.observableArray([]);
//updating x with some vales say {4 5 6 }
self.y = new ArrayDataProvider(self.x, { keyAttributes: "id" });

later, I m clearing this observable array
x.removeAll();

but I dont know how to clear data for ArrayDataProvider. plz help out.
Thanks

--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knock...@googlegroups.com.

Jonathan Shay

unread,
May 27, 2020, 7:31:50 AM5/27/20
to knock...@googlegroups.com

I’m not familiar with the ArrayDataProvider you reference, but it should be something along these lines:

 

self.x = ko.observableArray([]);

self.y = ko.computed(function(){

           return new ArrayDataProvider(self.x, { keyAttributes: "id" }); 

}, self);

 

 

Sent from Mail for Windows 10

To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/knockoutjs/1feacd9e-4088-4154-82a8-a861f9e2dbec%40googlegroups.com.

 

Reply all
Reply to author
Forward
0 new messages