problems with neotable and null values - Forum

Forum Navigation
You need to log in to create posts and topics.

problems with neotable and null values

Hi all, I have 2 problems.

1 Display is not the same when the column is defined editable or not. I do not want to see null (see image attached.

2 When I have null values I lost elements using ArrayAddItem. with the example below, I expect 9 elements but I have only 5 ??

CreateEmptyArray [aligne]
LoopObject [Prop] [neoTableRow]
If [Prop] != "ID"
ArrayAddItem [aligne] [neoTableRow([Prop])]
Endif
EndLoop

Uploaded files:
  • You need to login to have access to uploads.

@phil78 you should use the last neoTableSetColumn parameter: "Subroutine to format the data". In that subroutine you can check if  [value] == null and return any other string to show instead. Please check the included neoTable tutorial for more information and samples.

Regards.

OK @luishp and for the question 2 ?

Regards

@phil78 sorry I don't understand question 2. Please provide a working sample isolating the problem.
Thank you!

@luishp Here is an example. Keep your WE cool and anwer me next week.

Regards

Uploaded files:
  • You need to login to have access to uploads.

Hi @phil78. PLease take a close look at the LoopObject command in the help documentation. It's purpose is to retrieve object properties names. This would be the correct usage:

CreateEmptyArray [aligne]
LoopObject [Prop] [MyObjectVar]
  ArrayAddItem [aligne] [Prop]
EndLoop
ConsoleTable [aligne]

Then you will get the properties names listed.
I don't understand what was your original goal yet, sorry.

Regards.

Hi Luis

I know about loopobject ,

LoopObject [Prop] [MyObjectVar]
ArrayAddItem [aligne] [MyObjectVar([Prop])]

if you examine my code you will see the loop give me the property name, and after I call the value this property. Even if I write directly with the name ArrayAddItem [aligne] [MyObjectVar('P3')] I do not have an Item added. I think this is a bug !

I found a workaround but I have a new problem. If I copy an array of object using SetVar [Array2] [Array1] or ArrayCopy [Array1] 0 6 [Array2], when I modify after a value in Array1 it is also modified in Array2 ???

Regards

Hi @phil78,

Regarding null values, I think that's the way JavaScript works. Note that LoopObject translates to this JavaScript:  for (Prop in MyObjectVar)

If I copy an array of object using SetVar [Array2] [Array1] or ArrayCopy [Array1] 0 6 [Array2], when I modify after a value in Array1 it is also modified in Array2 ???

Please provide a complete sample so I can better understand you.
Anyway this is exactly what ArrayCopy does:

ArrayCopy = function(a, start, len) {
    if (a && start>-1 && len>0) return a.slice(start, start + len);
    return []
};

I think it should work fine but I'm curious about your example.

Regards

Hi @luishp,

Please, look at this example

Uploaded files:
  • You need to login to have access to uploads.

Hi @phil78. It seems you are trying to copy an Array whose elements are objects and not values.
Please take a look here to understand what's happening in your sample app:
https://stackoverflow.com/questions/29050004/modifying-a-copy-of-a-javascript-object-is-causing-the-original-object-to-change

Regards

 

Deleted user has reacted to this post.
Deleted user

@phil78 the attached sample will work as it clones objects instead of passing objects by reference.
Regards.

Uploaded files:
  • You need to login to have access to uploads.
Deleted user has reacted to this post.
Deleted user

Thanks a lot @luishp ,

indeed I replaced ArrayCopy with

StringifyJSON [mydata] [Temp]
ParseJSON "[Temp]" [array1]

and it works !

it would be interesting for java novices like me, to create a native visualneo function ArrayObjectCopy that does the operation directly. What do you think about it?

Best regards

 

luishp has reacted to this post.
luishp

@phil78 your solution is very smart :)