Good evening,
I am having a issue with setting pgData of the polygrid with a filtered array.
I am getting an error message that the value is not an array.
When I check the array is filtered correctly.
When I check the variable is still an array and when I use the answer message before setting the pgData I do get the correct answer.
The code is as follows:
command recipeSearch tSearch
put kittingItems into tKittingItems
if tSearch is empty then
set the pgData of widget "Recipes" of card "KittingItems" of me to kittingItems. -- this works as expected
else
filter elements of tKittingItems where each["itemDesc"] contains tSearch into tFiltered -- I checked and the array is correctly filtered
set the pgData of widget "Recipes" of card "KittingItems" of me to tFiltered. --I get an error here.
end if
end recipeSearch
I don't know what I am missing.
Thanks,
Markus
Polygrid : Property value is not a array
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Polygrid : Property value is not a array
Hi,
I think PG is a bit fussy with its array data.
Not sure what your array looks like but needs to be
1. Numerically keyed
2. Numerical index needs to start at 1
3. No gaps in numerical indexes ( ie 1,2,3,4,5, not 2,4,5)
Ie it should look like this:
Data grid is much more permissive that way, it just needs the indexes to be numerical, but in my experience, PG is a lot fussier about this.
Maybe that’s your issue?
I have a vague recollection this also affected me previously and I now rarely use PG because although it’s nice and simple, it’s just too constrained for my needs in many cases…DG isn’t as flashy but it does everything I need it to without headaches…
In your case as you are using filter without re-indexing the resultant array, PG is guaranteed to choke on that…
When I previously used PG with filtered arrays, I had to
1. Store the full array as a custom prop so it wasn’t lost
2. Store the index of the primal element filtered within the filtered element itself so I could reference the full array by the original index
3. Re-serialise the filtered array to start from 1 and be in sequence.
Data grid doesn’t need any of this of course, you can just assign the filtered array without worrying about indexes…
PS
I think PG is a bit fussy with its array data.
Not sure what your array looks like but needs to be
1. Numerically keyed
2. Numerical index needs to start at 1
3. No gaps in numerical indexes ( ie 1,2,3,4,5, not 2,4,5)
Ie it should look like this:
Code: Select all
PgData[1][data or sub array here ]
PgData[2][data or sub array here ]
PgData[3][data or sub array here ]
…
PgData[n][data or sub array here ]
Maybe that’s your issue?
I have a vague recollection this also affected me previously and I now rarely use PG because although it’s nice and simple, it’s just too constrained for my needs in many cases…DG isn’t as flashy but it does everything I need it to without headaches…
In your case as you are using filter without re-indexing the resultant array, PG is guaranteed to choke on that…
When I previously used PG with filtered arrays, I had to
1. Store the full array as a custom prop so it wasn’t lost
2. Store the index of the primal element filtered within the filtered element itself so I could reference the full array by the original index
3. Re-serialise the filtered array to start from 1 and be in sequence.
Data grid doesn’t need any of this of course, you can just assign the filtered array without worrying about indexes…
PS
Code: Select all
Please use code tags when showing code
This is the </> button above or
By surrounding code with [ code] [ /code] tags (spaces added to stop these from showing as code)
Re: Polygrid : Property value is not a array
Thank you for your insight on this.
I had to re-index the filtered array and now the code works as expected.
My data is not very large. If it was I think Datagrid would be the way to go.
Also thanks for making me aware of the code tag button.
Sincerely,
Markus
I had to re-index the filtered array and now the code works as expected.
My data is not very large. If it was I think Datagrid would be the way to go.
Also thanks for making me aware of the code tag button.
Code: Select all
command recipeSearch tSearch
put kittingItems into tKittingItems
if tSearch is empty then
set the pgData of widget "Recipes" of card "KittingItems" to kittingItems
else
filter elements of tKittingItems where each["itemDesc"] contains tSearch into tFiltered
put 0 into tcount
put empty into xkittingItems
repeat for each key tkey in tFiltered
add 1 to tcount
put tFiltered[tkey][itemNo] into xkittingItems[tcount][itemNo]
put tFiltered[tkey][remark] into xkittingItems[tcount][remark]
put tFiltered[tkey][kitNomber] into xkittingItems[tcount][kitNomber]
put tFiltered[tkey][itemDesc] into xkittingItems[tcount][itemDesc]
end repeat
set the pgData of widget "Recipes" of card "KittingItems" to xkittingItems
end if
end recipeSearch
Sincerely,
Markus
Re: Polygrid : Property value is not a array
Yeah that's what I had to do as well.
Because I use filter quite a lot with tables/listboxes and need to keep a reference to the original array so I can update a database or some such, I also add a line to the repeat loop to log the original key in the master array, prior to filtering, like
If changes are made, I put the equivalent of xkittingItems[tCount] into tKittingItems[tOriginalCount] if that makes sense...
Anyway glad it worked for you
Stam
Because I use filter quite a lot with tables/listboxes and need to keep a reference to the original array so I can update a database or some such, I also add a line to the repeat loop to log the original key in the master array, prior to filtering, like
Code: Select all
put tFiltered[tkey] into xkittingItems[tOriginalKey]
Anyway glad it worked for you

Stam
Re: Polygrid : Property value is not a array
It makes sense if you read it properly, and not as I did and had a mental image of kittens learning to knit snd counting stitches!