Page 1 of 2
check box selection in data grid and on a separate card
Posted: Wed Feb 26, 2014 12:07 pm
by keram
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
Re: check box selection in data grid and on a separate card
Posted: Thu Feb 27, 2014 2:35 am
by Simon
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
Re: check box selection in data grid and on a separate card
Posted: Thu Feb 27, 2014 10:56 am
by keram
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:
also all the lines above the selected checkbox line in the "My Selection" view disappear like here:
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
Re: check box selection in data grid and on a separate card
Posted: Thu Feb 27, 2014 11:14 am
by Simon
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
Re: check box selection in data grid and on a separate card
Posted: Thu Feb 27, 2014 11:56 am
by keram
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
Re: check box selection in data grid and on a separate card
Posted: Thu Feb 27, 2014 12:41 pm
by Simon
Remove "RefreshAllLines" from the button 'Behavior Script"
Re: check box selection in data grid and on a separate card
Posted: Thu Feb 27, 2014 3:07 pm
by keram
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
Re: check box selection in data grid and on a separate card
Posted: Fri Feb 28, 2014 5:33 am
by Simon
and it is among the items of gMySelectedLineNrs
No it isn't, look again.
Simon
Re: check box selection in data grid and on a separate card
Posted: Fri Feb 28, 2014 5:55 am
by keram
But is it in the code for the button checkbox (the very first on the top on this page/thread)??
Re: check box selection in data grid and on a separate card
Posted: Fri Feb 28, 2014 6:20 am
by Simon
You missed my point.
What is among the items of gMySelectedLineNrs???
Simon
Re: check box selection in data grid and on a separate card
Posted: Fri Feb 28, 2014 6:57 am
by keram
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?
Re: check box selection in data grid and on a separate card
Posted: Fri Feb 28, 2014 7:03 am
by Simon
Here is a question for you:
Is L among the items of LOOK ?
Simon
ps hint below
Hint: What is the itemDel?
Re: check box selection in data grid and on a separate card
Posted: Fri Feb 28, 2014 7:11 am
by keram
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
Re: check box selection in data grid and on a separate card
Posted: Fri Feb 28, 2014 7:14 am
by Simon
OK Alright already!
2 is not among the items of 002
Re: check box selection in data grid and on a separate card
Posted: Fri Feb 28, 2014 7:18 am
by keram
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