This is a migrated thread and some comments may be shown as answers.

Node gets dirty when is selected

4 Answers 125 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Juan Jose
Top achievements
Rank 1
Juan Jose asked on 27 Oct 2015, 11:49 AM

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.

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 29 Oct 2015, 11:51 AM
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!
 
0
Juan Jose
Top achievements
Rank 1
answered on 29 Oct 2015, 12:19 PM

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.

0
Daniel
Telerik team
answered on 02 Nov 2015, 09:50 AM
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!
 
0
Juan Jose
Top achievements
Rank 1
answered on 03 Nov 2015, 08:04 AM

Hi again,

that's all i need to know.

Thanks for the info.

Tags
TreeView
Asked by
Juan Jose
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Juan Jose
Top achievements
Rank 1
Share this question
or