Grid get data

Hey everyone,

Is there an easy way to get the data from a grid as collection?
Like gridobject.getAllItems();

Kind regards,

Sjoerd Brauer

Hi,

you will need to get the data from your DataProvider. How are you setting the data into your Grid?

-Olli

Hi Olli,

Im setting the data in the grid like:
gridobject.setItems(input);
where input is: List<objects>

Then the easiest way to get the items in the Grid is just from that input list; you might store it in a class member field or something.

-Olli

Hi Olli,

Thank you for your reply in my case that’s not really possible.
I posted this under Grid but I’m actually using GridPro where the entity inside the grid changes it’s value.
I could change the value of item in the list ofc, but I threw that reference away somewhere along the line.

My workaround is to select all items from the list and get them with the getselected (forgot the syntax) method.
I thought because GridPro en Grid is very similar I posted it here.

You could try this…

 ((ListDataProvider<T>)grid.getDataProvider()).getItems();

Stuart

Note that this will only work if you are using a ListDataProvider; Using grid.setItems() will create one implicitly.

Thanks Stuart and Olli for the help!

The code stuart gave works!

Stuart Robinson:
You could try this…

 ((ListDataProvider<T>)grid.getDataProvider()).getItems();

Stuart