Page 1 of 1

How to get selected file in filelist into datagrid?

Posted: Tue Aug 23, 2016 11:27 pm
by tusa
How can i get a selected file in a filelist into a datagrid?

Best regards Tue.

Re: How to get selected file in filelist into datagrid?

Posted: Wed Aug 24, 2016 12:44 am
by dunbarx
Hi.

A dataGrid is a complex LC object, comprised of fields and behaviors. But at heart it accepts and displays tab and return delimited data.

So if your file is so formatted, all you need to do is to:

Code: Select all

set the dgText of group "yourDG" to yourFileDataProperlyFormatted
It just goes in. From there, well, that is up to you. It requires patience and experience to manipulate and manage the contents and functionality of data grids, but that comes with time.

Craig Newman

Re: How to get selected file in filelist into datagrid?

Posted: Fri Aug 26, 2016 10:56 am
by tusa
I have this filelist "Skabeloner" with files in, when I select a file, only that filename should appear in my datagrid field "Skabelon"?

Right now i'm using this bit of code:

Code: Select all

put the field "FileList" into theDataA["Skabelon"]
and that puts all the filenames in the field "Skabelon" in my datagrid.

Re: How to get selected file in filelist into datagrid?

Posted: Fri Aug 26, 2016 11:07 am
by Klaus
Hi tusa,

1. welcome to the forum! :D

2. We need a bit more info from you!

Do you have a script in the field on the left side like:

Code: Select all

on mouseup
   ### put the field "FileList" into theDataA["Skabelon"]
   ### Do not use THE when addressing LC objects!
   put field "FileList" into theDataA["Skabelon"]
   set the dgdata of grp "your dg here" to theDataA
end mouseup
?

And do you really only want to have the selected filename in the datagrid?
I thought you want the CONTENT of that file in the datagrid?
If yes, where are these files?
In the list field there are only the filenames and not the pathnames to these files.

And yes -> put fld "XYZ" into whatever
will put the complete content of field "XYZ" into a variable named "whatever"

Here some great learning resources for the basics of Livecode, which are essential!
http://www.hyperactivesw.com/revscriptc ... ences.html


Best

Klaus

Re: How to get selected file in filelist into datagrid?

Posted: Fri Aug 26, 2016 11:19 am
by tusa
Hey Klaus.

I have a script, when I press a button.
I only need the filename as I select in the filelist.

And now I got it working:

Code: Select all

put the selectedText of field "FileList" into theDataA["Skabelon"]
put only the selected filename into the datagrid... YES!

How do then put the selected value from a combobox in my datagrid?

Re: How to get selected file in filelist into datagrid?

Posted: Fri Aug 26, 2016 11:31 am
by Klaus
Hi tusa,
tusa wrote:...
How do then put the selected value from a combobox in my datagrid?
Add this script to the combo-box:

Code: Select all

on menupick tSelectedMenuItem
  put tSelectedMenuItem into XXXX
end menuick
You can of course use shorter variable names than "tSelectedMenuItem"
I just used this to show you what will be in that parameter!

And you need to replace XXXX in the script with what- and whereever you need
that value in your datagrid.

If you use -> theDataA["Skabelon"]
that will overwrite your complete datagrid.

Same if you use -> theDataA["Lag"]
Maybe preserve the current data in the datagrid and just ADD the "Lag" column:

Code: Select all

on menupick tSelectedMenuItem
  put the dgdata of grp "your dg here" into theData
  put tSelectedMenuItem into theData[1]["Lag"]
  set the dgdata of grp "your dg here" to theData
end menuick
This will only affect line 1 of your datagrid.
As you see, it starts to get a bit copmplicated, but that is the nature of datagrids unfortunately. :D

Check these pages and download the datagrid documantation as PDF from that page:
http://lessons.livecode.com/m/datagrid
Hint: the download link is hidden in tiny fontsize on the left side under "Topics".


Best

Klaus

Re: How to get selected file in filelist into datagrid?

Posted: Sat Aug 27, 2016 7:24 am
by tusa
Just what I needed, Now I can get both the selected text in the filelist into my datagrid and I can get my checkbox data...
Tank you.