List data change event firing on selection


#1

I’m not sure if this is happening with other components or not, but I have a List with a function that fires on the “Change” event for the data of the list. The function calls my API to update the database, and displays a message when the update is complete. I noticed that every time I clicked on an item in the list to select it, I was getting a message indicating that the update had completed. It appears that selecting the item in the list adds a property named “$selected” and sets it to true.

This is actually corrupting my data because I use a field to track the last user to modify a record; that field is getting modified every time an item is selected in the list, making it entirely useless.

Is there a way to have the “change” event not be fired if the only change is the “$selected” property?


#2

Please, try to use edit events of the dhtmlxList to control the edit operations in your list:
https://docs.dhtmlx.com/suite/list__api__list_aftereditend_event.html
https://docs.dhtmlx.com/suite/list__api__list_aftereditstart_event.html
https://docs.dhtmlx.com/suite/list__api__list_beforeeditend_event.html
https://docs.dhtmlx.com/suite/list__api__list_beforeeditstart_event.html


#3

I’m not using the edit operations of the list, so I don’t think these won’t help me. I’m actually using a form to set multiple data fields, which are all represented within the template of the list item. I’m then using that form data to update the DataCollection object of the list. I was then using the change event of the DataCollection object to do AJAX calls to update my database. This works fine for all components except the List component. I haven’t seen the $selected field in the data for any of the other components, so it’s my thought that it’s specific to just the List.


#4

I’ve modified the List Data Loading sample snippet to demonstrate the behavior: https://snippet.dhtmlx.com/ppdj77hq

Click on any item in the list, and you’ll see it fires the “change” event with a status of “update”. If you look at the console log in the developer’s tools, it shows the $selected property in the updatedItem object.

In my view, the DataCollection object shouldn’t be modified by selection actions, but I don’t know the intricacies or complexities of selecting items in the List component. At the very least, modifications to the $selected property should be ignored in regards to firing the “change” event.