Looping through rows in Nebula Grid - eclipse-rcp

I have a Nebula Grid with rows of data in it.
How do I loop through each row to capture data from it?
Thank you.

I just came across this on my own endeavours to find an answer to my own question. Anyways, looping through a nebulagrids rows (or griditems, as they are called) can be accomplished like this:
GridItem[] itemList = grid.getItems();
for(GridItem item:itemList){
System.out.println(item.getText());
}
Depending on the data you want to retrieve from an item you will have to replace item.getText() with something to your own liking.

Related

How can I pre-select Ag-Grid rows from React state?

When rows are selected by the user, I save which rows are selected in some state. When the grid is rendered, I want those rows to still be selected. I've tried in onModelChanged calling setSelected on all the selected rows. However, this is not performant when lots of rows are selected. Also, there is a visible moment before the rows are selected, which is not ideal.
Is there any way I can pre-select rows before the grid is rendered?
I managed to select a row by using firstDataRendered event.
gridAPI.addEventListener(
"firstDataRendered",
({ api }) => {
// Has to wait until the next tick
setTimeout(() => {
api.getDisplayedRowAtIndex(0).selectThisNode(true);
}, 0);
},
);
Is there any way I can pre-select rows before the grid is rendered?
I assume that you are looking for configuration like editable for columns (its configurable), columns exist after gridReady event, but rows - only after firstRenderer event.
On top of that there are no properties for rows and as far as I know (and also double-checked on doc) there is no settings for that.
I mean you can configure lots of things, but the selection is out of it.
And on their examples, they are using forEach for that.
Yes you can preselect rows like below example.
onGridReady(params) {
this.gridOptions.api.forEachNode(node=> node.rowIndex === 1 ? node.setSelected (true) : node.setSelected(false));
}
You can make condition based on your state.
You can use firstDataRendered. Then loop on each node to set the data as selected. Hope this helps you!

Swift - print each item in an array to different rows on a UILabel

I am completely new to Swift but am loving my journey so far. I was wondering if anyone could help me with a slight issue of mine.
I am currently trying to print each item in an array to a different row on a UILabel.
I should be using a for loop but I am wondering how to structure the inside of the loop so that each item in the array prints on a separate line of the label.
As a bonus question, would a label even be the best way to display this? (Especially if the array has a lot of items). Maybe a ScrollView?
Thanks in advance for any responses. All help is appreciated.
The easiest way would be the following.
// Label will show as many lines as needed
label.numberOfLines = 0
// Join strings with new line characters so each string is a separate line
label.text = arrayOfStrings.joined(separator: "\n")

Xamarin Forms SearchBar + ListView slow to update

I would like some help into speeding up the process of filtering a long list of list items and viewing them on a ListView.
My app has a search bar, a ListView and a very long list of strings to choose from.
When the user enter a search term, the ListView is updated with every key stroke and filter out the irrelevant items.
Sorting itself takes a few milliseconds, but updating the ListView afterwards with the new filter-event takes a long time (20 seconds easy, if only a single character has been entered as search criteria)
I believe the time is spent on inflating a large number of ViewCells every time the filtered list updates.
Do any of you know how to speed up the process? I thought the way it could work was to have a very limited number of ViewCells (like 10 or 20) and then have them update and just show a selection of the filtered list. Scrolling would to be reusing the top/bottom one, update the content and put it back on the bottom/top - but I have not been able to wrap my head around how to do this.
Maybe it is the wrong approach and you know a better way?
I just had a similar problem that my list with just 20 elements would search extremely slow. Maybe your problem is similar. Sadly you didn't post any code. I had something like this:
List l = originalItems.Where((i) => i.Name.Contains(filterText));
listView.ItemsSource = l;
And I could not understand why this would be so slow. I found a different approach with more overhead that for some reason is faster and more responsive and overall feels better for the user. My ListView always has an ObservableCollection as ItemsSource. When I filter I calculate the difference to this ObservableCollection (the extra items and the removed items) and then remove or add accordingly. This avoids replacing the ItemsSource property which seems to be too harsh on the ListView.
//property of the class
ObservableCollection<FlightListItem> listViewItems;
// ....
//somewhere at initialization
listView.ItemsSoure = listViewItems;
// ....
//in the filter method:
List l = originalItems.Where((i) => i.Name.Contains(filterText));
IEnumerable itemsToAdd = l.Except(listViewItems).ToList();
IEnumerable itemsToRemove = listViewItems.Except(l).ToList();
listView.BeginRefresh();
foreach (FlightListItem item in removes)
listViewItems.Remove(item);
foreach (FlightListItem item in added)
listViewItems.Add(item);
listView.EndRefresh();
Notes:
removing the listView.BeginRefresh() and EndRefresh() did not seem to impact performance, but it seems the right thing to call them here.
We need to call ToList() on the itemsToAdd and itemsToRemove even though we only need IEnumerables! This is because Except is a lazy operation and will otherwise only be evaluated during the for loop. However during the for loop one of the parameters to Except changes which leads to an IllegalArgumentException due to modifying an IEnumerable while going over it.
If anyone knows a good filterable observable collection that would probably be a nicer solution.

How to build an Array or Nested Array to display in UITableView and then sort by certain objectAtIndex?

Sorry for such a confusing title but it's hard to explain in a few words what I'm trying to accomplish. I'll try to explain the best I can. Ok, I'm parsing data from a xml file. It's constructed like so:
<item1>
<subitem1>text</subitem1>
<subitem2>text</subitem2>
<subitem3>text</subitem3>
<subitem4>text</subitem4>
<subitem5>text</subitem5>
</item1>
<item2>
<subitem1>text</subitem1>
<subitem2>text</subitem2>
<subitem3>text</subitem3>
<subitem4>text</subitem4>
<subitem5>text</subitem5>
</item2>
<item3>
<subitem1>text</subitem1>
<subitem2>text</subitem2>
<subitem3>text</subitem3>
<subitem4>text</subitem4>
<subitem5>text</subitem5>
</item3>
so on and so on...
So basically I want to display each item into a separate row in a UITableView and put each subitem into it's parent's row/cell as a label to display the info about it's parent "item".
Also, I need to be able to sort each item by one of it's subitems i.e. let's say subitem4. If subitem4 is equal to some string then it would display that item into the UITableView however if subitem4 isn't equal to that string I compare it to then that item wouldn't get displayed in the UITableView. As of right now I really don't have any working code because I'm not sure how to go about making this work. I don't know how I would do this because I have 1 array right now with all of the subitems together and I'm just separating each subitem and putting them into separate arrays so I can distinguish between each item row, I'm do it with the following code:
int totalNames = [Names count];
id name = [Names objectAtIndex:1];
[listOfItems addObject:name];
I'm pretty sure I'm going about this the wrong way. There must be a better way to do this logically. Any help or advice would be much appreciated. I'm mentally exhausted with this. Thanks.
Use classes.
Make each Item an instance of a class. make each subitem a property of the class. then have one array of the objects. then can sort based on a particular property or whatever.

DataGridViewComboBoxCell selectioindexchange event

I have a data-grid and three column in it. one column is type of DataGridViewComboBoxCell, three items are in this grid combo box, now i have to invoke selection index changed event to change value according to combo value change in grid.
also help me to make a new event ....
please help...
thanks
I really can't understand your question.
But maybe these informations can help:
A ComboBoxColumn has always two kinds of controls. A presenting one (in most cases a label) which is individually for each row. And a editing one that will be shared for the whole column. So take a look into this documentation and the IDataGridViewEditingControl Interface.
Maybe these will give you a starting point on how to solve your problem.
In the Load event for the form, you need to get the cell that you want to add the handler to and cast it as a regular combo box. You can then add the event handler on SelectedIndexChanged, but it must be done programmatically, and depending on the language you are using.