Find rows in a datagrid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Find rows in a datagrid
I am using dgh_FindIndexes to find the comma delimited list of indices of rows in a datagrid that match a certain set of criteria. That is working just fine and I could set the dgHilitedIndexes to identify them. Rather than do that, I would like to delete all the rows that are not in the list of indices. I could dispatch "deleteIndexes" to the datagrid if I had the list of indices that complemented those found. My problem is in finding that list. Any suggestions?
Thanks, Larry
Thanks, Larry
Re: Find rows in a datagrid
Is the old fashioned way, to get the dgText, do your finagling, and then reset, an option?
I always feel comfortable with this sort of thing because I can use friendly LC gadgetry instead of fearsome DG gadgetry. The two extra steps required are nothing, to me.
Craig Newman
I always feel comfortable with this sort of thing because I can use friendly LC gadgetry instead of fearsome DG gadgetry. The two extra steps required are nothing, to me.
Craig Newman
Re: Find rows in a datagrid
Hi Larry,
this is how to compute your missing list:
1
2
...
## up to:
the number of lines of your datagrid
-> MINUS: each item in the result of your dgh_FindIndexes function
Get the picture?
Best
Klaus
this is how to compute your missing list:
1
2
...
## up to:
the number of lines of your datagrid
-> MINUS: each item in the result of your dgh_FindIndexes function
Get the picture?
Best
Klaus
Re: Find rows in a datagrid
The "dgh" is not what is giving me the problem and it is very efficient at getting the initial list of the ones I want to keep. It is getting rid of the others where my problem occurs. Here is a bit of the code that I have tried:
The problem comes with itemOffset. When tIndexes="9,10,11" and i=1, nPos turns out to equal 2. Consequently the row whose index is 1 does not get added to tToDelete and is not deleted from the grid.
Larry
Code: Select all
dgh_FindIndexes the long id of group tGrid, tField, tCondition, tValue
put the result into tIndexes
put empty into tToDelete
put the dgData of group tGrid into tData
put the number of elements of tData into tCount
repeat with i=1 to tCount
put i into tString
put itemOffset(tString,tIndexes) into nPos
if nPos=0 then
put i & comma after tToDelete
end if
end repeat
dispatch "deleteIndexes" to group tGrid with tToDelete
Larry
Re: Find rows in a datagrid
Hi Larry,
add this line right before the repeat loop:
Best
Klaus
add this line right before the repeat loop:
Code: Select all
...
## !
set the wholematches to true
## !
repeat with...
...
Klaus
Re: Find rows in a datagrid
Thanks Klaus,
That is one I never knew.
Larry
That is one I never knew.
Larry