Page 1 of 1

DataGrid, SQLite and texts with return

Posted: Mon Aug 10, 2020 5:01 pm
by Immanuel
Hello community

I have the following problem:

I'm filling a DataGrid from an SQLite database, so far so good.

Now the problem. I have a field that serves as an InfoText field and of course a text with "return" is stored there. When saving to the SQLite database there is no problem but when I try to fill the DataGrid again there are problems because every return is interpreted as a new line.

How can I get a multiline text that contains several return lines to be interacted with in the DataGrid?

Re: DataGrid, SQLite and texts with return

Posted: Mon Aug 10, 2020 5:21 pm
by dunbarx
Hi.

Prepare a dataSet that is tab and return delimited, either as an array or as clear data. The DG will accept that directly, by setting the DGText or the DGData.

Craig

Re: DataGrid, SQLite and texts with return

Posted: Mon Aug 10, 2020 5:36 pm
by Immanuel
and how do I do that? without whom a return in a field is it does not make me a new line?

Re: DataGrid, SQLite and texts with return

Posted: Mon Aug 10, 2020 7:50 pm
by dunbarx
Hi.

Now I am not sure what you mean. A datGrid is a large complicated beast, but the data it holds is available in part with native calls to its API, or in its entirety with the properties "DGData" or the "DGText". Getting and setting these last is how I usually deal with DG's.

If I wanted to insert three lines, inserted after, say, the current line 6 of the DG, one might:

Code: Select all

get the DGText of group "yourDatagrid"
put return & yourThreeLines after line 6 of it
set the DGText of group "yourDataGrid to it
Untested, but should work. What do you need that is different? Remember that those three lines must contain tab and return delimited data.

Craig

Re: DataGrid, SQLite and texts with return

Posted: Tue Aug 11, 2020 3:00 am
by dunbarx
there are problems because every return is interpreted as a new line.

How can I get a multiline text that contains several return lines to be interacted with in the DataGrid?
Is it that you want three "ordinary" lines, delimited by returns as is usual, to load into a single line in the DG? If so, just strip out the returns:

Code: Select all

replace return with "" in yourData
or

Code: Select all

replace return with space in yourData
But this may not format correctly. Does the data include tabs, which are used by the DG to delimit columns?

Craig

Re: DataGrid, SQLite and texts with return

Posted: Tue Aug 11, 2020 9:42 am
by stam
I can see the issue you're describing - using dgText and dgData will be an issue if your text contains carriage returns and create extra lines as you describe.

Of course one way to do this is to get rid of returns, but his may not suit your purposes.

I don't know how others have solved this, but one possible way to go about it would be to store the data in a custom property as an array, then populate the column using the fillInData pData event in the behaviour script (you'd need to create a column behaviour or row template beforehand if you're using a grid or form respectively). That way you'd fill the column with the actual data you retrieve from your database (with carriage returns and all).

Possibly there is a slicker way of doing this, but i'm fairly sure the above would work too...

Re: DataGrid, SQLite and texts with return

Posted: Tue Aug 11, 2020 2:35 pm
by FourthWorld
Details on the problem, with a solution handler:
http://www.fourthworld.com/embassy/arti ... t-die.html

Re: DataGrid, SQLite and texts with return

Posted: Tue Aug 11, 2020 3:31 pm
by Immanuel
Hello, everybody,

I have solved my problem completely.

i have created a second table in the database in which the info text with all characters a user can think of is stored and then i call it up separately in relation to the ID of the first table and put it in an extra field.

thank you for your effort i am sure i will ask for your help more often in the near future.