jQuery.Gantt
                                
                                 jQuery.Gantt copied to clipboard
                                
                                    jQuery.Gantt copied to clipboard
                            
                            
                            
                        Provide default item data to `onItemClick` handler (was: Why the onItemClick data is null)
I just download the latest codes and add one line code to onItemClick() of index.html alert("Item clicked - show some details"); alert("data = " + data);
then I click the item, the "Item clicked - show some details" showed, and then showed "data = null". Does any body knows why? Many thanks.
BTW, if I added two lines to onAddClick() alert("dt = " + dt); alert("rowId = "+ rowId);
dt = 13248000000 shows, but the second alerts shows "rowId = undefined".
Many thanks. Dan
Hi @ideallorn! Thanks for reporting this.
The main issue you're seeing is that the dataObj is not defined on any of the Gantt items in the demo, so it will appear as null.
As for the undefined rowId in onAddClick, this is a known issue that is fixed in the next release. See #116 and 5776d00.
I'm closing this for now, but please feel free to comment if you have more questions or new information. Thanks again!
In values add dataObj.
public class Values { private String from; private String to; private String label; private String customClass; private String dataObj; }
Hello @czh030509, and thanks for your request. It seems like a good idea to add some default data to the chart items based on what was used to initialize them.
I wouldn't make dataObj its own property of this object, since it would not be backwards compatible with the existing functionality.
Instead, I would suggest the default object to be something like $.extend({}, {from, to, label, customClass}, dataObj). This is still technically not backwards compatible for the use case where someone implements logic based on the presence/absence of these entries in their custom object.
This needs a little more thought and discussion, and it probably would not be included before the next major version of the plugin.
Thanks again for making the request—I'm reopening the issue & clarifying the name.