Non-sql dataset

Hello everyone,

I’m trying to do something that seems like it shouldn’t be hard, but for the life of me I cannot figure it out. :slight_smile:

I have a simple window, with a table, a button, and an editable text field. The data from the table is imported from a CSV file on the internalframeActivated event of the window. No problems there.

The left-most column in the table is a PO Number(string, actually), which I want to be able to search for. I want to be able to type a corresponding number into the text field, and click the button, returning the row containing it. With a table connected to a database, this is easy as pie. But I can’t seem to find any information on doing it on a dataset alone.

Any thoughts/ideas would be appreciated!

Hi AustinVDT,

This can be done easily with a little scripting.

First add a custom property to your table to hold your unsearched dataset. Perhaps call this custom property CSVData. Fill this property with your CSV data. Also fill your property with the CSV data to start with.

When a user types a search term in a text field and presses the search button take the search term and loop through the CSVData custom property dataset looking for a match in the PO Number column. When you find a match create a new dataset from the row that was a match and assign it to the data property of the table.

Here’s some code that shows how to search through a dataset and create a new dataset with matching rows that are found. This could be put on the actionPerformed event of the search button.

table = event.source.parent.getComponent('Table') tableCols = list(table.CSVData.getColumnNames()) searchText = event.source.parent.getComponent('Text Field').text searchResultsData = [] for row in range(table.CSVData.getRowCount()): if table.CSVData.getValueAt(row,"PO Number") == searchText: rowValues = [] for col in tableCols: rowValues.append(table.CSVData.getValueAt(row,col)) searchResultsData.append(rowValues) = system.dataset.toDataSet(tableCols,searchResultsData) This is a simple example. A whole lot of additional functionality could be added to this.

1 Like

Nmudge, that’s exactly what I wanted–it worked perfectly :slight_smile:

I was kind of on the right track, but so often I forget the power of a custom property!

Thanks a lot! :prayer: