Select in Data Grid

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

SEAL29
Posts: 63
Joined: Fri Oct 02, 2020 3:32 pm

Select in Data Grid

Post by SEAL29 » Sun Oct 04, 2020 8:56 am

How to do that by selecting a row in the data grid then jump to that card using a button.
So i have one list with different titles and every title lead on different card, i select one title and jump that card with pressing button?
I put it wrong but I can't describe it any other way.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Select in Data Grid

Post by richmond62 » Sun Oct 04, 2020 9:39 am

How to do that by selecting a row in the data grid then jump to that card using a button.
1. select a row in a datagrid.

2. "jump to that card".

part 1 is easy-peasy, lemon-squeezy:

Code: Select all

on mouseDown
   put the clickline into fld "fLineClicked"
end mouseDown
part 2 makes me wonder what you mean by "that card".

a) If you mean that you want to use a datagrid as a navigation menu, I think you are over-doing things a bit:
personally I'd just "go for" a scrolling list field . . .

BECAUSE when I click on my DG with that script above the data the line contains does NOT end up in the output.
-
Screenshot 2020-10-04 at 11.14.01.png
-

This screws up in a Datagrid:

Code: Select all

on mouseDown
   put the selectedText of me into fld "fLineClickedx"
end mouseDown
BUT works perfectly in a listField. 8)
-
Screenshot 2020-10-04 at 11.25.00.png
-

Code: Select all

on mouseDown
   put the selectedText of me into XXX
   go to card XXX
end mouseDown
-
Screenshot 2020-10-04 at 11.38.02.png
Last edited by richmond62 on Sun Oct 04, 2020 9:44 am, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Select in Data Grid

Post by richmond62 » Sun Oct 04, 2020 9:41 am

Here's my stack with the listField.
Attachments
Navi - Gator.livecode.zip
Here's the stack.
(2.41 KiB) Downloaded 207 times

SEAL29
Posts: 63
Joined: Fri Oct 02, 2020 3:32 pm

Re: Select in Data Grid

Post by SEAL29 » Sun Oct 04, 2020 12:05 pm

This is it, thank you.

klamp
Posts: 18
Joined: Sun Sep 20, 2020 10:36 am

Re: Select in Data Grid

Post by klamp » Sun Oct 04, 2020 12:23 pm

Thank you for the senior members of the livecode. It is very helpful for the sample stack that you provide. :D

SEAL29
Posts: 63
Joined: Fri Oct 02, 2020 3:32 pm

Re: Select in Data Grid

Post by SEAL29 » Sun Oct 04, 2020 1:06 pm

How can i add in Scrolling List Field each new text on a new line with button? There is a field in which I type the text and copy it in the Scrolling List Field with buton.
I now use this code, but it always copies only one line and deletes the previous word.

Code: Select all

on mouseUp pMouseButton
   set the text of field "scrollingList" to the text of field "titleField"
   record the text in field "scrollingList"
end mouseUp

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Select in Data Grid

Post by richmond62 » Sun Oct 04, 2020 3:51 pm

Well: you have to do a bit more than that:

1. You have to add a new line of text in your listField.

2. You have to add a new card to the stack with the same name as the line of text you have put in your listField.

Button: ADD NEW ITEM:

Code: Select all

on mouseUp
   ask "Text for new item: "
   put it into KKK
   put 1 into KOUNT
   repeat until line KOUNT of field "SLF" is empty
      add 1 to KOUNT
   end repeat
   put KKK into line KOUNT of field "SLF"
   create card KKK
   go first card
end mouseUp
The ONLY PROBLEM is I cannot work out how to inject a script into a new card to set its title to its name.
-
Screenshot 2020-10-04 at 17.49.12.png
-
Attachments
Navi - Gator2.livecode.zip
Here's the stack.
(2.62 KiB) Downloaded 222 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Select in Data Grid

Post by richmond62 » Sun Oct 04, 2020 4:05 pm

Why am I so good at saying I cannot work something out just before I do? 8)

Code: Select all

on mouseUp
   ask "Text for new item: "
   put it into KKK
   put 1 into KOUNT
   repeat until line KOUNT of field "SLF" is empty
      add 1 to KOUNT
   end repeat
   put KKK into line KOUNT of field "SLF"
   create card KKK
   set the script of card KKK to ((fld "s1" of card "HOME") && KKK & quote & cr & (fld "s2" of card "HOME"))
   go first card
end mouseUp
-
Screenshot 2020-10-04 at 18.01.58.png
-
Screenshot 2020-10-04 at 18.02.08.png
-

"OFF" to have Etwas dunkles Bier. 8)
Attachments
Navi - Gator3.livecode.zip
Here's the stack.
(2.84 KiB) Downloaded 223 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Select in Data Grid

Post by richmond62 » Sun Oct 04, 2020 4:08 pm

BUT . . . just before I go, I would like to state that the ONLY way I am ever likely to use a dataGrid is
if someone cocks a gun at my head . . .

. . . I am sure they are "all very clever and useful in their way", but I'd far rather stick to
listFields and tableFields.

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

Re: Select in Data Grid

Post by dunbarx » Sun Oct 04, 2020 4:49 pm

What Richmond really meant, even being held hostage by his own hand, is that new users often use dataGrids too soon.

DataGrids are compact, elegant and powerful tools, written by one of our most resourceful members. But they have their own API and are complex. They are attractive to those new users I mentioned because they seem to have everything one could ask for in a single package.

They do.

But they have a learning curve quite apart from LiveCode's own, and are often not nearly necessary to implement the functionality required. I am in no way trying to steer anyone away from learning about them. But I am advising that the more basic controls be examined first, since they are far simpler to use, and oftentimes do just what Richmond said, work just fine.

Craig

SEAL29
Posts: 63
Joined: Fri Oct 02, 2020 3:32 pm

Re: Select in Data Grid

Post by SEAL29 » Sun Oct 04, 2020 5:05 pm

The 3rd Navi - Gator is work perfectly great thanks for this.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Select in Data Grid

Post by richmond62 » Sun Oct 04, 2020 6:22 pm

headspace.jpg
-
Kein dunkles Bier, aber gut genug für mich.

Thinking about things, I think I'd modify the contents of field "s1" to this:

Code: Select all

on openCard
   set the title of this stack to "

So that 'card fishface' is just called 'fishface' instead. 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Select in Data Grid

Post by richmond62 » Fri Oct 09, 2020 8:48 am

From "somewhere else":
could import the title from an existing field into the scrolling-list-field by jumping to that current card. So I'm not typing in an address, I'm importing an existing one.
The problem that I can see about this is that the code bunging the title of a field on a car into a line in a scrolling
list field (SLF) would have to be in that card's cardScript, so, everytime one went to that card it would pop the name of the field
on that card into a line in the SLF.
-
Roco.jpg

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Select in Data Grid

Post by richmond62 » Sat Oct 10, 2020 8:38 am

Actually that is pretty silly . . .

1. The listing in the inital SLF is of card names: if those are changed to the titles of textFields residing on those cards
the navigational capacity will be lost . . .

2. So: if you really think "that is the way to go" you might want to put the name of the textField into the second item of a more complex scrolling field.
-
DD.jpeg
DD.jpeg (6.85 KiB) Viewed 6726 times
-
https://youtu.be/pr3zpqp3ypY
-
Well; there's one way to go. 8)

HOWEVER . . . a tableField will NOT accept mouseDown signals in the same way as a SLF.
-
Screenshot 2020-10-10 at 10.48.39.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: Select in Data Grid

Post by richmond62 » Sat Oct 10, 2020 9:05 am

Screenshot 2020-10-10 at 11.01.29.png
-
I think you are going to have a problem.

For example on my card "fishpie" I have a field called "How to cook Rotis", and that is all very jazzy, BUT if
our code is going to be in the cardScript to put the name of that field into item 2 [{Delimited lines] of the
card's line in the SLF on the first card of the stack HOW is it going to refer to the field without ALREADY knowing its name?

Post Reply