jQuery.Gantt icon indicating copy to clipboard operation
jQuery.Gantt copied to clipboard

Provide default item data to `onItemClick` handler (was: Why the onItemClick data is null)

Open ideallorn opened this issue 10 years ago • 3 comments

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

ideallorn avatar May 11 '15 10:05 ideallorn

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!

usmonster avatar May 12 '15 12:05 usmonster

In values add dataObj.

public class Values { private String from; private String to; private String label; private String customClass; private String dataObj; }

czh030509 avatar Feb 24 '18 08:02 czh030509

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.

usmonster avatar Feb 24 '18 21:02 usmonster