Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ideallorn opened this issue May 11, 2015 · 3 comments

Comments

@ideallorn
Copy link

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

@usmonster
Copy link
Collaborator

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!

@czh030509
Copy link

In values add dataObj.

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

@usmonster
Copy link
Collaborator

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 usmonster reopened this Feb 24, 2018
@usmonster usmonster changed the title Why the onItemClick data is null Provide default item data to onItemClick handler (was: Why the onItemClick data is null) Feb 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants