Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.

    JesseNinjaTrader Customer Service

    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.
        JesseNinjaTrader Customer Service

        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.



            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by kaywai, 09-01-2023, 08:44 PM
            5 responses
            601 views
            0 likes
            Last Post NinjaTrader_Jason  
            Started by xiinteractive, 04-09-2024, 08:08 AM
            6 responses
            22 views
            0 likes
            Last Post xiinteractive  
            Started by Pattontje, Yesterday, 02:10 PM
            2 responses
            16 views
            0 likes
            Last Post Pattontje  
            Started by flybuzz, 04-21-2024, 04:07 PM
            17 responses
            229 views
            0 likes
            Last Post TradingLoss  
            Started by agclub, 04-21-2024, 08:57 PM
            3 responses
            17 views
            0 likes
            Last Post TradingLoss  
            Working...
            X