check box selection in data grid and on a separate card

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

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

check box selection in data grid and on a separate card

Post by keram » Wed Feb 26, 2014 12:07 pm

Hello,

I have 2 cards in a stack (attached). Card 1 shows few text lines that can be selected with a checkbox an viewed by sclicking on the 'My Selection' button.
Toggling selection of lines and switching between 'All Lines' view and 'My Selection' view works OK - the checkboxes get selected/diselected in a proper way.

When I click on the text line itself I go to a card 2 showing the whole text line. On that card I placed a checkbox to be able to toggle selection as well.
But that checkbox is not selecting/diselecting the checkboxes properly on the previous card or previous view.

I've used this code for the checkbox:

Code: Select all

global gAllLines,gMySelection,gMySelectedLineNrs,gCurentIndex

on mouseUp
   set the itemDelimiter to tab
   
   if the hilite of me is "true" then
      put "true" into item 2 of line gCurentIndex of gMySelection
      put "true" into item 2 of line gCurentIndex of gAllLines
   else 
      put "false" into item 2 of line gCurentIndex of gMySelection
      put "false" into item 2 of line gCurentIndex of gAllLines
   end if
   
   RefreshAllLines
end mouseUp
   

and this code for the card it is on:

Code: Select all

global gMySelection,gMySelectedLineNrs,gCurrentLineNr,gCurrentLine,gCurentIndex

on openCard
   set itemDel to tab
   put gCurentIndex into fld "a" --- used during development
   put gCurrentLine into fld "b" --- used during development
   if gCurentIndex is among the items of gMySelectedLineNrs then
      set the hilite of btn "Check" to "true"
   else
      set the hilite of btn "Check" to "false"
   end if

end openCard
the rest of the code you can see on the level of stack in the attached file.

Any ideas how to correct this?

Thanks in advance.

keram
Attachments
DG-checkbox selection.zip
(55.46 KiB) Downloaded 194 times
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: check box selection in data grid and on a separate card

Post by Simon » Thu Feb 27, 2014 2:35 am

Hi keram,
OK I found it but you'll need to change a lot.

1) you need to set the itemDel in RefreshAllLines
2) add send mouseUp to btn "All Lines" of cd "main" to the end of RefreshAllLines (this is just for the refresh dg stuff)
3) remove (send "RefreshList" to grp "DataGrid 1" --update changes from btn All lines) from btn All Lines
4) add

Code: Select all

on openCard
   dispatch "ResetList" to group "DataGrid 1"
end openCard
to cd "main"
There are a few additions of "DataGrid 1" of cd "main" to DataArray

And you still are not done...
Your toggle is not designed correctly in the script of btn "check". I'll let you work on that.

I think those were the only changes I made :)

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: check box selection in data grid and on a separate card

Post by keram » Thu Feb 27, 2014 10:56 am

Hi Simon,

Thanks for your corrections which are now included in the attached stack.
Simon wrote:2) add send mouseUp to btn "All Lines" of cd "main" to the end of RefreshAllLines (this is just for the refresh dg stuff)
After adding this line all the lines above the selected checkbox line in the "All Lines"view disappear like here:
1.jpg
also all the lines above the selected checkbox line in the "My Selection" view disappear like here:
2.jpg
The selection from the cd "oneline" stays now in the other views but still is not picking up the hilite status when opening that cd and is not remaining there after returning to that cd.
Simon wrote:Your toggle is not designed correctly in the script of btn "check". I'll let you work on that.
I tried to find similar example on the forum but could not find any...
Simon wrote:There are a few additions of "DataGrid 1" of cd "main" to DataArray
More than what you mentioned here? :?

keram
Attachments
DG-checkbox selection2.zip
(55.5 KiB) Downloaded 202 times
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: check box selection in data grid and on a separate card

Post by Simon » Thu Feb 27, 2014 11:14 am

Funny, I don't get the missing lines when using this most recent stack?
Tell me the steps (what do you click on) to get these results.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: check box selection in data grid and on a separate card

Post by keram » Thu Feb 27, 2014 11:56 am

Hi Simon,

Here are the steps:

1. open the stack (no checkboxes are selected)
2. start selecting some checkboxes in "All Lines" view, e.g. nr 003, then all the lines above 3 will disappear, then select nr 007 and all the ones above 007 will disappear, etc.
3. Select "My Selection" view and dis-select checkbox of 3rd line and all the checkboxes above it will disappear.

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: check box selection in data grid and on a separate card

Post by Simon » Thu Feb 27, 2014 12:41 pm

Remove "RefreshAllLines" from the button 'Behavior Script"
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: check box selection in data grid and on a separate card

Post by keram » Thu Feb 27, 2014 3:07 pm

Thanks Simon,

It works OK now, except the checkbox hilites on cd "oneline" - I don't understand why the checkbox is not picking up the hilite state with this code:

Code: Select all

    global gMySelection,gMySelectedLineNrs,gCurrentLineNr,gCurrentLine,gCurentIndex

    on openCard
       set itemDel to tab
       put gCurentIndex into fld "a" --- used during development
       put gCurrentLine into fld "b" --- used during development
       if gCurentIndex is among the items of gMySelectedLineNrs then
          set the hilite of btn "Check" to "true"
       else
          set the hilite of btn "Check" to "false"
       end if

    end openCard
Index number of the current/visible line is correct and it is among the items of gMySelectedLineNrs and yet the hilite does not change.
I'm missing something here...

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: check box selection in data grid and on a separate card

Post by Simon » Fri Feb 28, 2014 5:33 am

and it is among the items of gMySelectedLineNrs
No it isn't, look again.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: check box selection in data grid and on a separate card

Post by keram » Fri Feb 28, 2014 5:55 am

But is it in the code for the button checkbox (the very first on the top on this page/thread)??
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: check box selection in data grid and on a separate card

Post by Simon » Fri Feb 28, 2014 6:20 am

You missed my point.
What is among the items of gMySelectedLineNrs???

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: check box selection in data grid and on a separate card

Post by keram » Fri Feb 28, 2014 6:57 am

gMySelectedLineNrs are the numbers of the lines that have true as their hilites. And if the gCurentIndex which is the line number of the line which is currently opened is among these hilited lines, then set the hilite of checkbox to true. What's wrong with this?
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: check box selection in data grid and on a separate card

Post by Simon » Fri Feb 28, 2014 7:03 am

Here is a question for you:
Is L among the items of LOOK ?



Simon
ps hint below


















Hint: What is the itemDel?
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: check box selection in data grid and on a separate card

Post by keram » Fri Feb 28, 2014 7:11 am

Simon wrote:Is L among the items of LOOK ?
it's not LOOK is just 1 item

gMySelectedLineNrs are TAB delimited numbers and that line is in the code
gCurentIndex is just a number
so I still don't understand what's wrong.

Thanks for your patience with me!

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: check box selection in data grid and on a separate card

Post by Simon » Fri Feb 28, 2014 7:14 am

OK Alright already! 8)

2 is not among the items of 002
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: check box selection in data grid and on a separate card

Post by keram » Fri Feb 28, 2014 7:18 am

Of course not.

But 5 = 005 and that's why I expected to be among the items of 002 003 007 009 005 004

So that's what was wrong?

keram
Last edited by keram on Fri Feb 28, 2014 7:21 am, edited 1 time in total.
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Post Reply