Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CollectionEditor clones on add

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    CollectionEditor clones on add

    There seem to have been a change in the NinjaTrader.Gui.Tools.CollectionEditor:
    When I add a new element it Clones an exisitng one (giving it a new name though - which the user can change back) instead of creating a new one. The result is that it's impossible to create a unique id for a given element. (As it clones the existing unique id too)

    Is this intended behaviour? If so what's the idea behind it or what is the way I should use it?
    Last edited by Zapzap; 12-10-2019, 07:52 AM.

    #2
    Hello Zapzap,

    Thank you for the post.

    I couldn't say if this would be expected or not as this is not a documented concept. I do see that a collection editor was used in the following sample.


    Can you check if the sample also exhibits the same behavior or modify it in a way which does and provide that back as a specific sample which demonstrates the problem?

    You mention that the element gets a new name however a collection editor would be intended to wrap a type such as an object or class with custom properties that you set. Are you relying on some auto generated id/name or do you have a specific property with a name that you set that is losing value? For example the above sample uses PercentWrapper class which inherits ICloneable so it can be cloned and retain its values.

    I look forward to being of further assistance.

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Can you check if the sample also exhibits the same behavior or modify it in a way which does and provide that back as a specific sample which demonstrates the problem?
      Yes, it does the same thing too. If you add a new element, it clones an existing one, instead of creating a new one.

      Originally posted by NinjaTrader_Jesse View Post
      You mention that the element gets a new name however a collection editor would be intended to wrap a type such as an object or class with custom properties that you set.
      Add a property: public string Name {get;set;} and it will take control of it. After cloning it adds a "1", then a "1 1", then a "1 1 1", etc. to the string if previous one exists. (this is a good idea though to reach a unique stte: still the user can modify it back to the original, making it non-unique)


      Originally posted by NinjaTrader_Jesse View Post
      Are you relying on some auto generated id/name or do you have a specific property with a name that you set that is losing value? For example the above sample uses PercentWrapper class which inherits ICloneable so it can be cloned and retain its values.
      In my list I need an always unique identifier, to be able to save, load and reference certain items later. But since a new element is cloned, all the properties from the cloned element get copied over to the new element - if I want the list and the editor functionable.

      See, the problem is that the editor uses the same Clone method to both create a new item and make a copy of an existing one for the sake of the propertygrid.
      In my view the Clone method of the Icloneable object should be used to show it in the propertygrid and the parameterless constructor of the object should be used when creating a new element for the list.



      Comment


        #4
        Hello Zapzap,

        Thanks for the additional details.

        Do you have a specific sample that you can provide which demonstrates the issue? I can put in a feature request to change the way this works however I would not have a specific solution that I can provide as an alternative. This is likely something you would need to try and account for with logic if at all possible in the use case.

        I look forward to being of further assistance.

        Comment


          #5
          I don't have a better sample than yours.
          Just maybe add the Name property to see how it changes.

          Comment


            #6
            Hello Zapzap,

            Could you make the modifications you are referring to and attach that as a sample along with the instructions to see the result you are describing?

            For this type of question I would not want to try and guess what you coded on your end, a specific sample and specific steps used would be best to provide this type of information to our support. You can modify our help guide sample, I would just want to see the specific modifications you made without guessing.

            I look forward to being of further assistance.



            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            566 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            330 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            547 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            548 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X