Okay, I'll give it a try. I used to be an interpreter in another life. @bbhank:
Using "revDataFromQuery(tab, cr, gConnectionID, tSQL)" tells LC to fetch the database data and when it receives that data, LC should put a carriage return after every row and tabs between each column. The characters you've chosen for the query will decide how LC sets up the data. Now imagine you have this data in the database:
Row 1 <tab> name 1 <tab> address 1
Row 2 <tab> name 2 <tab> address 2
Row 3 <tab> name 3 <tab> address line1 <cr>address line2<cr>address line3
The last row has a multiline cell. When LC receives that data, you've told it that carriage returns should separate rows, so it adds those for you:
Row 1 <tab> name 1 <tab> address 1 <cr>
Row 2 <tab> name 2 <tab> address 2<cr>
Row 3 <tab> name 3 <tab> address line1 <cr>address line2<cr>address line3<cr>
And when you make an array out of it, using a carriage return as the primary delimiter, you get five rows because that's how many carriage returns are in the text.
To avoid that, you need to tell LC to use something other than a carriage return when it sends the data back to your handler. You can use any character, but the ones axwald suggested are good because they can't be typed from the keyboard so you can be pretty sure the text itself won't contain those characters. But for display here, I'll use a pipe character:
Code: Select all
revDataFromQuery(tab, "|", gConnectionID, tSQL)
Now LC will give you back data with rows separated by pipes and with all CRs retained as part of the cell. Now you need to make an array from the data using pipe as the primary delimiter:
This retains the carriage returns if any exist in any cells. There is no harm doing the entire set of data this way. It will work whether the cells have returns in them or not. It also means you don't have to do any special processing when you fill the datagrid because your array will hold the correct values.
Note: if your data ever contains tabs, you'll run into the same problem except that it won't be rows, it'll be columns. Any record with tabs in it will create extra columns in that row. You should probably change the SQL request to use something other than tabs for the column delimiters too.