Node gets dirty when is selected

5 posts, 0 answers
  1. Juan Jose
    Juan Jose avatar
    45 posts
    Member since:
    Jul 2013

    Posted 27 Oct 2015 Link to this post

    Hello,

    I don't know if it's a bug or is the expected behaviour but when i select a node it is marked as dirty.

    Here is an example: http://dojo.telerik.com/OVUtO/3

    There is some way to prevent this behaviour?

    Thanks.

  2. Daniel
    Admin
    Daniel avatar
    2118 posts

    Posted 29 Oct 2015 Link to this post

    Hello,

    The behavior is expected. The dirty flag is changed because the selected field of the item will be changed when the node is selected. There isn't a way to prevent this but you could use the dataSource change event to set the previous dirty value when the selected field is changed e.g.
    function onChange(e) {
        if (e.field && e.action == "itemchange") {
            var model = e.items[0];
            model.dirtyState = model.dirtyState || e.field !== "selected";
            model.dirty = model.dirtyState;
        }
    }


    Regards,
    Daniel
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Juan Jose
    Juan Jose avatar
    45 posts
    Member since:
    Jul 2013

    Posted 29 Oct 2015 Link to this post

    Hello,

    Thanks for the answer, it works perfectly. I suppose that if i want to avoid this behaviour when a node is expanded, i just need to replace the code 

    e.field !== "selected"
    with

    (e.field !== "selected" && e.field !== "​expanded")

    I don't know if there is more events linked to navigation between nodes. I want to avoid the dirty state in this cases.

    Regards.

  5. Daniel
    Admin
    Daniel avatar
    2118 posts

    Posted 02 Nov 2015 Link to this post

    Hi,

    The updated condition should be sufficient. The only other field that will automatically be set by the treeview is the checked field.

    Regards,
    Daniel
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Juan Jose
    Juan Jose avatar
    45 posts
    Member since:
    Jul 2013

    Posted 03 Nov 2015 Link to this post

    Hi again,

    that's all i need to know.

    Thanks for the info.

Back to Top
Kendo UI is VS 2017 Ready