How to get selected file in filelist into datagrid?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
tusa
Posts: 36
Joined: Sun Jan 31, 2016 10:30 pm

How to get selected file in filelist into datagrid?

Post by tusa » Tue Aug 23, 2016 11:27 pm

How can i get a selected file in a filelist into a datagrid?

Best regards Tue.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10354
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Wed Aug 24, 2016 12:44 am

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

tusa
Posts: 36
Joined: Sun Jan 31, 2016 10:30 pm

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

Post by tusa » Fri Aug 26, 2016 10:56 am

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.
Attachments
Udklip.JPG

Klaus
Posts: 14208
Joined: Sat Apr 08, 2006 8:41 am
Contact:

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

Post by Klaus » Fri Aug 26, 2016 11:07 am

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

tusa
Posts: 36
Joined: Sun Jan 31, 2016 10:30 pm

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

Post by tusa » Fri Aug 26, 2016 11:19 am

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?

Klaus
Posts: 14208
Joined: Sat Apr 08, 2006 8:41 am
Contact:

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

Post by Klaus » Fri Aug 26, 2016 11:31 am

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

tusa
Posts: 36
Joined: Sun Jan 31, 2016 10:30 pm

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

Post by tusa » Sat Aug 27, 2016 7:24 am

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.

Post Reply